Implement resize for Vec#20044
Merged
Merged
Conversation
Contributor
|
r? @huonw (rust_highfive has picked a reviewer for you, use r? to override) |
Contributor
Author
|
r? @gankro |
Contributor
There was a problem hiding this comment.
Since this is about to be deprecated, this should be changed to an extend using repeat.
Contributor
Author
There was a problem hiding this comment.
So my brain is apparently just turned completely off right now...doesn't repeat yield the same value endlessly? How would you limit extend to only add the proper number of elements?
Contributor
There was a problem hiding this comment.
The full expression is self.extend(repeat(value).take(new_len - len))
Contributor
Author
There was a problem hiding this comment.
...and there is the missing piece. How I forgot that take was a thing is beyond me -_-
I guess when in doubt, just check IteratorExt :P
This commit adds `resize` to `Vec` in accordance with RFC 509.
Contributor
Author
|
@gankro Updated. |
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this pull request
Dec 21, 2014
This PR adds `resize()` to `Vec` in accordance with RFC 509.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds
resize()toVecin accordance with RFC 509.