Uh oh!
There was an error while loading. Please reload this page.
Implement .pop_opt() and .shift_opt() for vec - #7602
Conversation
bluss
commented
Jul 5, 2013
|
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()
bluss
commented
Jul 5, 2013
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 |
bblum
commented
Jul 5, 2013
I still think "sorry, cannot pop and empty vector" should stay. |
bluss
commented
Jul 6, 2013
should I push again? Or can bblum take back the r+? |
thestinger
commented
Jul 6, 2013
@blake2-ppc: you could just remove the commit and push |
bluss
commented
Jul 6, 2013
done. Unfortunately the discussion is gone with that. It was decided to not have "sorry" in any error messages. |
bluss
commented
Jul 6, 2013
previous discussion here: https://github.com/blake2-ppc/rust/commit/a8d72c108bbd60d32de32dd0eafba40e3bf31080#commitcomment-3575462 |
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()
…dnet Set applicability of needless_collect to MaybeIncorrect Fixesrust-lang#88333 changelog: Set applicability of [`needless_collect`] to MaybeIncorrect
7602: Check for dyn impls in method resolution r=flodiebold a=Veykril Fixesrust-lang#6777 Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
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()