Conversation
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @joboet (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
joboet
left a comment
There was a problem hiding this comment.
If the predicate modifies the value but returns false, that should be reflected in the vector. Hence this should call f with the value still in the vector, and only then remove it. Also, I'd prefer if this didn't use unsafe, I'd wager that the optimizer is able to deal with a combination of slice::last and Vec::pop just fine.
|
Fair enough, I'll trust your judgement on the optimizer. Switch to @rustbot review |
joboet
left a comment
There was a problem hiding this comment.
Looks great, thank you very much! Could you squash the commits, please?
Then r=me
(this shorthand tells other people with merge rights that they can merge this on my behalf if don't get to it right away)
29ca03d to
07d3806
Compare
|
@bors r=joboet |
|
@avandesa: 🔑 Insufficient privileges: Not in reviewers |
|
Ope, I misunderstood that I think |
|
@bors r=joboet |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#122439 (match lowering: build the `Place` instead of keeping a `PlaceBuilder` around) - rust-lang#122880 (Unix: Support more platforms with `preadv` and `pwritev`) - rust-lang#123038 (std library thread.rs: fix NetBSD code for ILP32 CPUs.) - rust-lang#123084 (`UnixStream`: override `read_buf`) - rust-lang#123102 (RustWrapper: update call for llvm/llvm-project@44d037cc258dcf179d2c48…) - rust-lang#123107 (Implement `Vec::pop_if`) - rust-lang#123118 (Update `RwLock` deadlock example to not use shadowing) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#123107 - avandesa:vec_pop_if, r=joboet Implement `Vec::pop_if` This PR adds `Vec::pop_if` to the public API, behind the `vec_pop_if` feature. ```rust impl<T> Vec<T> { pub fn pop_if<F>(&mut self, f: F) -> Option<T> where F: FnOnce(&mut T) -> bool; } ``` Tracking issue: rust-lang#122741 ## Open questions - [ ] Should the first unit test be split up? - [ ] I don't see any guidance on ordering of methods in impl blocks, should I move the method elsewhere?
This PR adds
Vec::pop_ifto the public API, behind thevec_pop_iffeature.Tracking issue: #122741
Open questions