Trait crow_util::traits::RetainMut [−][src]
pub trait RetainMut<T> { fn retain_mut<F>(&mut self, f: F)
where
F: FnMut(&mut T) -> bool; }
Used to remove all elements from a collection for which the predicate f
does not return true.
Required Methods
fn retain_mut<F>(&mut self, f: F) where
F: FnMut(&mut T) -> bool,
F: FnMut(&mut T) -> bool,
Retains only the elements specified by the predicate.
In other words, remove all elements e
such that f(&mut e)
returns false
.
This method operates in place and preserves the order of the retained
elements.
Examples
use crow_util::traits::*; let mut vec = vec![0, 1, 2, 3, 4, 5]; vec.retain_mut(|x| { *x += 1; *x % 2 == 0 } ); assert_eq!(vec, [2, 4, 6]);
Implementations on Foreign Types
impl<T> RetainMut<T> for Vec<T>
[src]
impl<T> RetainMut<T> for Vec<T>
fn retain_mut<F>(&mut self, f: F) where
F: FnMut(&mut T) -> bool,
[src]
fn retain_mut<F>(&mut self, f: F) where
F: FnMut(&mut T) -> bool,