Skip to content

Implement Vec::from_elem (RFC 832) #22455

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

Merged
merged 1 commit into from
Feb 18, 2015
Merged

Conversation

msiemens
Copy link
Contributor

Implement Vec::from_elem by making the vec![element; len] macro more powerful (see rust-lang/rfcs#832).

Closes #22414

r? @gankro

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @gankro (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see CONTRIBUTING.md for more information.

let mut ptr = v.as_mut_ptr();

// Write all elements except the last one
for i in range(1, n) {
Copy link
Contributor

Choose a reason for hiding this comment

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

range(1, n) -> 1..n (yes I know the RFC had this, I am dumb)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem :)

@Gankra
Copy link
Contributor

Gankra commented Feb 17, 2015

Ok this looks good to me, I'd just like @aturon or @alexcrichton to verify that public-stable-doc(hidden)-free-fn-in-std::vec is the way we want to go on this.

@Gankra
Copy link
Contributor

Gankra commented Feb 17, 2015

Ok IRC says this is the right approach. r=me with commits squashed.

Implement `Vec::from_elem` by making the `vec![element; len]` macro
more powerful (see RFC 832).

Closes rust-lang#22414
@msiemens
Copy link
Contributor Author

Great! I've squashed the commits as requested

@Gankra
Copy link
Contributor

Gankra commented Feb 17, 2015

@bors r+ 2bf553c rollup

@Gankra
Copy link
Contributor

Gankra commented Feb 17, 2015

Thanks, and great work!

❤️

@msiemens
Copy link
Contributor Author

Thanks for mentoring!

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Feb 18, 2015
Implement `Vec::from_elem` by making the `vec![element; len]` macro more powerful (see rust-lang/rfcs#832).

Closes rust-lang#22414

r? @gankro
@huonw huonw merged commit 2bf553c into rust-lang:master Feb 18, 2015
@msiemens msiemens deleted the add-vec-from_elem branch February 18, 2015 13:13
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.

Tracking issue: Add back Vec::from_elem (RFC 832)
4 participants