Uh oh!
There was an error while loading. Please reload this page.
Clarify behavior of VecDeque::insert. - #38581
Conversation
rust-highfive
commented
Dec 23, 2016
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. Due to 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 the contribution instructions for more information. |
frewsxcv
commented
Dec 23, 2016
I think my changes are an improvement, but I'm not super satisfied with them. Please let me know if anyone has ideas for improvement. |
1042e8a to
1f6b0b5CompareThere was a problem hiding this comment.
Could we just reuse the Vec comment: "Inserts an element at position index within the vector, shifting all elements after it to the right."? I don't know whether that has different meaning for VecDeque, but seems simpler.
Edit: Link to Vec documentation: https://doc.rust-lang.org/std/vec/struct.Vec.html#method.insert
There was a problem hiding this comment.
My hesitation with that comment is that (at least behind the scenes in memory), VecDeque::insert doesn't necessarily shift all the following items to the back like it does with Vec::insert. Though, if we're not talking about what happens in-memory it is true as far as indices/positions go, if that makes any sense. What do you think?
There was a problem hiding this comment.
Perhaps "Inserts an element at position index within the vector, incrementing all indices after index by one."
That avoids the problem with somewhat implying the underlying memory operations.
There was a problem hiding this comment.
Thanks for the suggestion. I incorporated it in the latest force push.
There was a problem hiding this comment.
Though on second thought, your suggestion doesn't really address #37046.
Looks like your PR / commit message title has a typo: |
1f6b0b5 to
c11705eCompareVecDequeue::insert.VecDeque::insert.frewsxcv
commented
Dec 24, 2016
@shepmaster Thanks for pointing that out. It's been fixed now. |
deec978 to
971a019Compare
Mark-Simulacrum
left a comment
There was a problem hiding this comment.
Looks good, left two minor nits.
There was a problem hiding this comment.
Maybe just "at index"? "index index" feels a little odd.
There was a problem hiding this comment.
Fixed in the latest force push.
There was a problem hiding this comment.
I'm not sure this will compile, but perhaps we can omit the & in front of each char in the array? Perhaps removing those and making it a slice will work.
There was a problem hiding this comment.
That didn't work for me:
error[E0277]: the trait bound `&char: std::cmp::PartialEq<char>` is not satisfied
--> <anon>:12:4
|
12 | assert_eq!(vec, &['a', 'd', 'b', 'c']);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::cmp::PartialEq<char>` is not implemented for `&char`
|
= help: the following implementations were found:
= help: <char as std::cmp::PartialEq>
= note: required because of the requirements on the impl of `std::cmp::PartialEq<&[char; 4]>` for `std::vec::Vec<&char>`
= note: this error originates in a macro outside of the current crate
error: aborting due to previous error
There was a problem hiding this comment.
Ah, I see the problem. Can you try changing vec_deque.iter().collect::<Vec<_>>(); to vec_deque.into_iter().collect::<Vec<_>>();? That should fix the compile error.
There was a problem hiding this comment.
Yep! Fixed in the latest force push.
971a019 to
8f68e23Compare8f68e23 to
0ab7812CompareGuillaumeGomez
commented
Jan 4, 2017
Thanks! @bors: r+ rollup |
bors
commented
Jan 4, 2017
📌 Commit 0ab7812 has been approved by |
…aumeGomez Clarify behavior of `VecDeque::insert`. Fixesrust-lang#37046.
…aumeGomez Clarify behavior of `VecDeque::insert`. Fixesrust-lang#37046.
bors
commented
Jan 9, 2017
⌛ Testing commit 0ab7812 with merge 96d3123... |
bors
commented
Jan 9, 2017
💔 Test failed - status-travis |
alexcrichton
commented
Jan 9, 2017
via email
@bors: retry
* network error …On Mon, Jan 9, 2017 at 8:06 AM, bors ***@***.***> wrote:
💔 Test failed - status-travis
<https://travis-ci.org/rust-lang/rust/builds/190296475>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#38581 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAD95PkY7pzNqSujpCBOZU50x7r00Jmbks5rQlrxgaJpZM4LVC9j>
.
|
bors
commented
Jan 9, 2017
Clarify behavior of `VecDeque::insert`. Fixes#37046.
bors
commented
Jan 9, 2017
☀️ Test successful - status-appveyor, status-travis |
Fixes#37046.