-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Implement reserve_len
and reserve_len_exact
for VecMap
#20143
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
r? @gankro |
/// | ||
/// The collection may reserve more space to avoid frequent reallocations. | ||
/// | ||
/// # Examples |
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.
I settled on the following wording in BitvSet:
/// Reserves capacity for the given `BitvSet` to contain `len` distinct elements. In the case
/// of `BitvSet` this means reallocations will not occur as long as all inserted elements
/// are less than `len`.
///
/// The collection may reserve more space to avoid frequent reallocations.
I worded this to clarify "why len" and future-proof for a possible future where Vec and RingBuf get it. Willing to bikeshed on it, though.
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.
So then would the correct wording for VecMap be to change the first sentence to
"Reserves capacity for the given VecMap
to contain len
distinct elements..." and then keep the rest of what I had, or should the second sentence be changed to mirror BitvSet too? Can't quite tell what would make sense
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.
Yeah s/BitvSet/VecMap; they have basically the same semantics (the high-level documentation even suggests that BitvSet is basically VecSet).
Only issue is the method description bikeshed. |
Also for posterity,
|
13f8241
to
8e7faaa
Compare
Method descriptions fixed. |
8e7faaa
to
868acdf
Compare
Alright, take 3! |
Implement `reserve_len` and `reserve_len_exact` for `VecMap` in accordance with rust-lang/rfcs#509.
Implement
reserve_len
andreserve_len_exact
forVecMap
in accordance with rust-lang/rfcs#509.