pub fn focus<P>(&mut self, mut p: P)
    where
        P: FnMut(&T) -> bool,
    {
        if let Some(position) = self.before.iter().position(&mut p) {
            for elem in self.before.drain(position..).rev() {
                self.after.push_front(elem);
            }
        } else if let Some(position) = self.after.iter().position(&mut p) {
            if position == 0 {
                return; // Already focused.
            }
            for elem in self.after.drain(..position) {
                self.before.push_back(elem);
            }
        } else {
            panic!("No element in stack matches predicate");
        }
    }
/// Focuses the first element in the stack that matches the predicate.
///
/// # Panics
///
/// Panics if no element matches the predicate.
Focuses the first element in the stack that matches the predicate.
Focuses the first element in the stack that matches the predicate .
pub fn focus<P>(&mut self, mut p: P)
    where
        P: FnMut(&T) -> bool,
    {
        if let Some(position) = self.before.iter().position(&mut p) {
            for elem in self.before.drain(position..).rev() {
                self.after.push_front(elem);
            }
        } else if let Some(position) = self.after.iter().position(&mut p) {
            if position == 0 {
                return; // Already focused.
            }
            for elem in self.after.drain(..position) {
                self.before.push_back(elem);
            }
        } else {
            panic!("No element in stack matches predicate");
        }
    }
pub fn focus < P > ( & mut self , mut p : P ) where P : FnMut ( & T ) -> bool , { if let Some ( position ) = self . before . iter ( ) . position ( & mut p ) { for elem in self . before . drain ( position .. ) . rev ( ) { self . after . push_front ( elem ) ; } } else if let Some ( position ) = self . after . iter ( ) . position ( & mut p ) { if position == 0 { return ; // Already focused. } for elem in self . after . drain ( .. position ) { self . before . push_back ( elem ) ; } } else { panic ! ( " " ) ; } }
Focuses the first element in the stack that matches the predicate.
Focuses the first element in the stack that matches the predicate .
&mut self
p
P
panics
Panics if no element matches the predicate.
Panics if no element matches the predicate .