pub fn remove_with<F>(&mut self, key: K, remove: F) -> impl Iterator<Item = V>
    where
        F: FnMut(&V) -> bool,
    {
        match self.map.entry(key) {
            Entry::Occupied(mut entry) => {
                let queue = entry.get_mut();
                let (remove, keep) = queue.drain(..).partition::<Vec<_>, _>(remove);
                if keep.is_empty() {
                    // no items left - remove whole entry
                    entry.remove();
                } else {
                    // put remaining items back
                    queue.extend(keep);
                }
                remove.into_iter()
            }
            Entry::Vacant(_) => vec![].into_iter(),
        }
    }
/// Removes items on key `k` that satisfy `remove` predicate
/// Returns removed items. Keeps other items by reinserting them to queue.
/// If there's no items left after removal, removes key.
Removes items on key `k` that satisfy `remove` predicate
Returns removed items. Keeps other items by reinserting them to queue.
If there's no items left after removal, removes key.
Removes items on key ` k ` that satisfy ` remove ` predicate Returns removed items . Keeps other items by reinserting them to queue . If there ' s no items left after removal removes key .
pub fn remove_with<F>(&mut self, key: K, remove: F) -> impl Iterator<Item = V>
    where
        F: FnMut(&V) -> bool,
    {
        match self.map.entry(key) {
            Entry::Occupied(mut entry) => {
                let queue = entry.get_mut();
                let (remove, keep) = queue.drain(..).partition::<Vec<_>, _>(remove);
                if keep.is_empty() {
                    // no items left - remove whole entry
                    entry.remove();
                } else {
                    // put remaining items back
                    queue.extend(keep);
                }
                remove.into_iter()
            }
            Entry::Vacant(_) => vec![].into_iter(),
        }
    }
pub fn remove_with < F > ( & mut self , key : K , remove : F ) -> impl Iterator < Item = V > where F : FnMut ( & V ) -> bool , { match self . map . entry ( key ) { Entry :: Occupied ( mut entry ) => { let queue = entry . get_mut ( ) ; let ( remove , keep ) = queue . drain ( .. ) . partition :: < Vec < _ > , _ > ( remove ) ; if keep . is_empty ( ) { // no items left - remove whole entry entry . remove ( ) ; } else { // put remaining items back queue . extend ( keep ) ; } remove . into_iter ( ) } Entry :: Vacant ( _ ) => vec ! [ ] . into_iter ( ) , } }
Removes items on key `k` that satisfy `remove` predicate
Returns removed items.
Removes items on key ` k ` that satisfy ` remove ` predicate Returns removed items .
&mut self
key
K
remove
F