Skip to content

add append to vec with tests and benchmarks - #21330

Merged
bors merged 1 commit into
rust-lang:masterfrom
JeffBelgum:collections-reform-issue-19986-add-append-and-split-off
Jan 18, 2015
Merged

add append to vec with tests and benchmarks#21330
bors merged 1 commit into
rust-lang:masterfrom
JeffBelgum:collections-reform-issue-19986-add-append-and-split-off

Conversation

@JeffBelgum

Copy link
Copy Markdown
Contributor

Please review carefully. Contains unsafe and is my first commit to Rust.

Uses ptr::copy_nonoverlapping_memory. Attempts to handle zero-size types correctly.

@rust-highfive

Copy link
Copy Markdown
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (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.

Comment threadsrc/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.

Does vec![] not infer correctly here?

@Gankra

Copy link
Copy Markdown
Contributor

Generally we only add benchmarks when we're trying to establish that a change has a desired performance impact. Adding them for every feature is kinda unwieldy (just slows everything else down).

@Gankra

Copy link
Copy Markdown
Contributor

Actual code seems legit, just style nits.

👍

@JeffBelgum

Copy link
Copy Markdown
ContributorAuthor

I've addressed the previous comments.

@Gankra

Copy link
Copy Markdown
Contributor

Oh derp. Yeah no worries.

Comment threadsrc/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.

I would still drop these benches.

@Gankra

Copy link
Copy Markdown
Contributor

r=me with benches removed, and commits squashed.

@JeffBelgum
JeffBelgumforce-pushed the collections-reform-issue-19986-add-append-and-split-off branch from 74e4f3e to 08e712eCompareJanuary 18, 2015 00:15
@JeffBelgum

Copy link
Copy Markdown
ContributorAuthor

r=Gankro

bors added a commit that referenced this pull request Jan 18, 2015
…-add-append-and-split-off, r=Gankro
Please review carefully. Contains unsafe and is my first commit to Rust.
Uses ptr::copy_nonoverlapping_memory. Attempts to handle zero-size types correctly.
@bors
bors merged commit 08e712e into rust-lang:masterJan 18, 2015
@Gankra

Copy link
Copy Markdown
Contributor

Congrats!

Hope to see more from you in the future. 😄

@mneumann

Copy link
Copy Markdown
Contributor

I am a bit unhappy about the naming, as it's moving the elements out of the argument. I wouldn't expect that. But I don't have a better name for it...

@Gankra

Copy link
Copy Markdown
Contributor

This name was accepted in an RFC: rust-lang/rfcs#509

@mneumann

Copy link
Copy Markdown
Contributor

ok. would have been cleaner to have sth. like move in the name, suggesting that the items are actually moved, but then move_append sounds ugly. I am fine with append, but still it might be unintuitive and someone might expect the argument vector still to contain the values...

@andrewrk

Copy link
Copy Markdown

Why does move_append sound ugly? It describes exactly what the function does.

@mneumann

Copy link
Copy Markdown
Contributor

@andrewrk: Hm, after thinking about it, yesmove_append describes exactly what it does! Given the fact that append in it's current form is an optimization so that you can reuse it's argument, I'd rather go with consuming it's argument append(&mut self, other: Self) and rename it's current form into the more-dangerous-to-usemove_append(&mut self, other: &mut Self).

@mneumann

Copy link
Copy Markdown
Contributor

Ok, we have push_all which clones and append which moves. Without consulting the documentation it's not obvious to me which one does which.

@Gankra

Copy link
Copy Markdown
Contributor

basically nothing in Rust actually uses the term move

@Gankra

Copy link
Copy Markdown
Contributor

And push_all is a non-normative performance hack

@huonw

Copy link
Copy Markdown
Contributor

basically nothing in Rust actually uses the term move

(There's move || ... closures.)

@mneumann

Copy link
Copy Markdown
Contributor

@gankro: In the past there was move_iter() IIRC which has been renamed to into_iter(). I am still living in the past :D

lnicola pushed a commit to lnicola/rust that referenced this pull request Dec 31, 2025
Sign up for freeto 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.

8 participants

@JeffBelgum@rust-highfive@Gankra@mneumann@andrewrk@huonw@brson@bors