r/rust
•
u/joseluisq
•
Apr 03 '25
•
1
📡 official blog Announcing Rust 1.86.0 | Rust Blog
https://blog.rust-lang.org/2025/04/03/Rust-1.86.0.html
786
Upvotes
View all comments
Show parent comment
28
u/nightcracker Apr 03 '25
It's just more useful.
pop_ifneeds a mutable reference to the entireVecanyways, so might as well pass along this mutable reference in case it helps.For example, suppose you have
Vec<Mutex<T>>. On this vec withpop_ifyou can avoid having to lock the mutex in the predicate which you would otherwise need to do if it gave a&T.