pub fn retain(&mut self, mut predicate: impl FnMut(Index, &mut T) -> bool) {
        for i in 0..self.capacity() as u32 {
            let remove = match &mut self.items[i as usize] {
                Entry::Occupied { generation, value } => {
                    let index = Index {
                        index: i,
                        generation: *generation,
                    };
                    if predicate(index, value) {
                        None
                    } else {
                        Some(index)
                    }
                }

                _ => None,
            };
            if let Some(index) = remove {
                self.remove(index);
            }
        }
    }
/// Retains only the elements specified by the predicate.
///
/// In other words, remove all indices such that `predicate(index, &value)` returns `false`.
///
/// # Examples
///
/// ```ignore
/// use rapier::data::arena::Arena;
///
/// let mut crew = Arena::new();
/// crew.extend(&["Jim Hawkins", "John Silver", "Alexander Smollett", "Israel Hands"]);
/// let pirates = ["John Silver", "Israel Hands"]; // too dangerous to keep them around
/// crew.retain(|_index, member| !pirates.contains(member));
/// let mut crew_members = crew.iter().map(|(_, member)| **member);
/// assert_eq!(crew_members.next(), Some("Jim Hawkins"));
/// assert_eq!(crew_members.next(), Some("Alexander Smollett"));
/// assert!(crew_members.next().is_none());
/// ```
Retains only the elements specified by the predicate.
In other words, remove all indices such that `predicate(index, &value)` returns `false`.
Retains only the elements specified by the predicate . In other words remove all indices such that ` predicate ( index &value ) ` returns ` false ` .
pub fn retain(&mut self, mut predicate: impl FnMut(Index, &mut T) -> bool) {
        for i in 0..self.capacity() as u32 {
            let remove = match &mut self.items[i as usize] {
                Entry::Occupied { generation, value } => {
                    let index = Index {
                        index: i,
                        generation: *generation,
                    };
                    if predicate(index, value) {
                        None
                    } else {
                        Some(index)
                    }
                }
                _ => None,
            };
            if let Some(index) = remove {
                self.remove(index);
            }
        }
    }
pub fn retain ( & mut self , mut predicate : impl FnMut ( Index , & mut T ) -> bool ) { for i in 0 .. self . capacity ( ) as u32 { let remove = match & mut self . items [ i as usize ] { Entry :: Occupied { generation , value } => { let index = Index { index : i , generation : * generation , } ; if predicate ( index , value ) { None } else { Some ( index ) } } _ => None , } ; if let Some ( index ) = remove { self . remove ( index ) ; } } }
Retains only the elements specified by the predicate.
Retains only the elements specified by the predicate .
&mut self
predicate
impl FnMut(Index, &mut T) -> bool
examples
```ignore
use rapier::data::arena::Arena.

let mut crew = Arena::new();
crew.extend(&["Jim Hawkins", "John Silver", "Alexander Smollett", "Israel Hands"]);
let pirates = ["John Silver", "Israel Hands"]; // too dangerous to keep them around
crew.retain(|_index, member| !pirates.contains(member));
let mut crew_members = crew.iter().map(|(_, member)| **member);
assert_eq!(crew_members.next(), Some("Jim Hawkins"));
assert_eq!(crew_members.next(), Some("Alexander Smollett"));
assert!(crew_members.next().is_none());
```
` ` ` ignore use rapier :: data :: arena :: Arena . let mut crew = Arena :: new () ; crew . extend ( & [ " Jim Hawkins " " John Silver " " Alexander Smollett " " Israel Hands " ] ) ; let pirates = [ " John Silver " " Israel Hands " ] ; // too dangerous to keep them around crew . retain ( |_index member| !pirates . contains ( member )) ; let mut crew_members = crew . iter () . map ( | ( _ member ) | ** member ) ; assert_eq! ( crew_members . next () Some ( " Jim Hawkins " )) ; assert_eq! ( crew_members . next () Some ( " Alexander Smollett " )) ; assert! ( crew_members . next () . is_none () ) ; ` ` `