fn take_chain_if<F>(&mut self, predicate: F) -> Option<Box<Chain>>
    where
        F: Fn(&Chain) -> bool,
    {
        let chains = mem::take(&mut self.chain_set);
        let mut best_chain_iter = chains.into_iter().rev();

        while let Some(next_best_chain) = best_chain_iter.next() {
            // if the predicate says we should remove it
            if predicate(&next_best_chain) {
                // add back the remaining chains
                for remaining_chain in best_chain_iter {
                    self.chain_set.insert(remaining_chain);
                }

                // and return the chain
                return Some(next_best_chain);
            } else {
                // add the chain back to the set and continue
                self.chain_set.insert(next_best_chain);
            }
        }

        None
    }
/// Remove and return the first chain satisfying the given predicate.
Remove and return the first chain satisfying the given predicate.
Remove and return the first chain satisfying the given predicate .
fn take_chain_if<F>(&mut self, predicate: F) -> Option<Box<Chain>>
    where
        F: Fn(&Chain) -> bool,
    {
        let chains = mem::take(&mut self.chain_set);
        let mut best_chain_iter = chains.into_iter().rev();
        while let Some(next_best_chain) = best_chain_iter.next() {
            // if the predicate says we should remove it
            if predicate(&next_best_chain) {
                // add back the remaining chains
                for remaining_chain in best_chain_iter {
                    self.chain_set.insert(remaining_chain);
                }
                // and return the chain
                return Some(next_best_chain);
            } else {
                // add the chain back to the set and continue
                self.chain_set.insert(next_best_chain);
            }
        }
        None
    }
fn take_chain_if < F > ( & mut self , predicate : F ) -> Option < Box < Chain > > where F : Fn ( & Chain ) -> bool , { let chains = mem :: take ( & mut self . chain_set ) ; let mut best_chain_iter = chains . into_iter ( ) . rev ( ) ; while let Some ( next_best_chain ) = best_chain_iter . next ( ) { // if the predicate says we should remove it if predicate ( & next_best_chain ) { // add back the remaining chains for remaining_chain in best_chain_iter { self . chain_set . insert ( remaining_chain ) ; } // and return the chain return Some ( next_best_chain ) ; } else { // add the chain back to the set and continue self . chain_set . insert ( next_best_chain ) ; } } None }
Remove and return the first chain satisfying the given predicate.
Remove and return the first chain satisfying the given predicate .
&mut self
predicate
F