-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add notes about capacity effects to Vec::truncate() #39738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
Is this an implementation detail or something we want to guarantee? |
src/libcollections/vec.rs
Outdated
@@ -545,6 +545,9 @@ impl<T> Vec<T> { | |||
/// The [`drain`] method can emulate `truncate`, but causes the excess | |||
/// elements to be returned instead of dropped. | |||
/// | |||
/// Note that his method has no effect on the allocated capacity | |||
/// of the vector. | |||
/// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "his"
src/libcollections/vec.rs
Outdated
@@ -1089,6 +1092,9 @@ impl<T> Vec<T> { | |||
|
|||
/// Clears the vector, removing all values. | |||
/// | |||
/// Note that this method has no effect on the allocated capacity | |||
/// of the vector, and is equivalent to calling `truncate(0)`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this comment be a little less specific about the implementation? As it stands, the implementation is in the comment itself. (I am being a little paranoid here.)
Could you also update the similar methods on |
0d00bd6
to
4be5783
Compare
@brson Are there any outstanding issues here? |
Sounds good to me. Thanks a lot for this add! @bors: r+ rollup |
📌 Commit 4be5783 has been approved by |
Add notes about capacity effects to Vec::truncate() Add notes about the effects of Vec::truncate() and Vec::clear() on the capacity of a vector.
☀️ Test successful - status-appveyor, status-travis |
Add notes about the effects of Vec::truncate() and Vec::clear() on the capacity of a vector.