Skip to content

Implement resize for Vec#20044

Merged
bors merged 1 commit into
rust-lang:masterfrom
csouth3:vec-resize
Dec 22, 2014
Merged

Implement resize for Vec#20044
bors merged 1 commit into
rust-lang:masterfrom
csouth3:vec-resize

Conversation

@csouth3

@csouth3 csouth3 commented Dec 19, 2014

Copy link
Copy Markdown
Contributor

This PR adds resize() to Vec in accordance with RFC 509.

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @huonw

(rust_highfive has picked a reviewer for you, use r? to override)

@csouth3

csouth3 commented Dec 19, 2014

Copy link
Copy Markdown
Contributor Author

r? @gankro

@rust-highfive rust-highfive assigned Gankra and unassigned huonw Dec 19, 2014
Comment thread src/libcollections/vec.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is about to be deprecated, this should be changed to an extend using repeat.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The full expression is self.extend(repeat(value).take(new_len - len))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...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.
@csouth3

csouth3 commented Dec 19, 2014

Copy link
Copy Markdown
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.
@bors
bors merged commit d61db0c into rust-lang:master Dec 22, 2014
@csouth3
csouth3 deleted the vec-resize branch December 22, 2014 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants