Implement .pop_opt() and .shift_opt() for vec#7602
Closed
bluss wants to merge 2 commits intorust-lang:masterfrom
bluss:vec-pop-opt
Closed
Implement .pop_opt() and .shift_opt() for vec#7602bluss wants to merge 2 commits intorust-lang:masterfrom bluss:vec-pop-opt
bluss wants to merge 2 commits intorust-lang:masterfrom
bluss:vec-pop-opt
Conversation
Contributor
Author
|
|
added 2 commits
July 5, 2013 20:32
Add a function to safely retrieve the last element of a ~[T], as Option<T>. Implement pop() using pop_opt(); it benches the same as the old implementation when tested with optimization level 2.
Add a function to safely retrieve the first element of a ~[T], as Option<T>. Implement shift() using shift_opt(). Add tests for both .shift() and .shift_opt()
Contributor
Author
|
Pushed again to fix the doc comments for push and push_opt. It should be "removes last element" for pop. Edit: I meant pop and not push here. Brain farts... too many of em |
Contributor
|
I still think "sorry, cannot pop and empty vector" should stay. |
Contributor
Author
|
should I push again? Or can bblum take back the r+? |
Contributor
|
@blake2-ppc: you could just remove the commit and push |
Contributor
Author
|
done. Unfortunately the discussion is gone with that. It was decided to not have "sorry" in any error messages. |
Contributor
Author
bors
added a commit
that referenced
this pull request
Jul 7, 2013
Implement methods `.pop_opt() -> Option<T>` and `.shift_opt() -> Option<T>` to allow retrieval of front/back of a vec in one operation without fail. .pop() and .shift() are changed to reuse the former two methods. Follows the naming of the previous method .head_opt()
flip1995
pushed a commit
to flip1995/rust
that referenced
this pull request
Sep 3, 2021
…dnet Set applicability of needless_collect to MaybeIncorrect Fixes rust-lang#88333 changelog: Set applicability of [`needless_collect`] to MaybeIncorrect
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.
Implement methods
.pop_opt() -> Option<T>and.shift_opt() -> Option<T>to allow retrieval of front/back of a vec in one operation without fail. .pop() and .shift() are changed to reuse the former two methods.Follows the naming of the previous method .head_opt()