/// Appends an element to the ring buffer.
/// On failure returns an error containing the element that hasn't beed appended.
Appends an element to the ring buffer.
On failure returns an error containing the element that hasn't beed appended.
Appends an element to the ring buffer . On failure returns an error containing the element that hasn ' t beed appended .
pub fn push(&mut self, elem: T) -> Result<(), PushError<T>> {
        let mut elem_opt = Some(elem);
        match unsafe { self.push_access(|slice, _| {
            mem::forget(mem::replace(&mut slice[0], elem_opt.take().unwrap()));
            Ok((1, ()))
        }) } {
            Ok(res) => match res {
                Ok((n, ())) => {
                    debug_assert_eq!(n, 1);
                    Ok(())
                },
                Err(()) => unreachable!(),
            },
            Err(e) => match e {
                PushAccessError::Full => Err(PushError::Full(elem_opt.unwrap())),
                PushAccessError::BadLen => unreachable!(),
            }
        }
    }
pub fn push ( & mut self , elem : T ) -> Result < ( ) , PushError < T > > { let mut elem_opt = Some ( elem ) ; match unsafe { self . push_access ( | slice , _ | { mem :: forget ( mem :: replace ( & mut slice [ 0 ] , elem_opt . take ( ) . unwrap ( ) ) ) ; Ok ( ( 1 , ( ) ) ) } ) } { Ok ( res ) => match res { Ok ( ( n , ( ) ) ) => { debug_assert_eq ! ( n 1 ) ; Ok ( ( ) ) } , Err ( ( ) ) => unreachable ! ( ) , } , Err ( e ) => match e { PushAccessError :: Full => Err ( PushError :: Full ( elem_opt . unwrap ( ) ) ) , PushAccessError :: BadLen => unreachable ! ( ) , } } }
Appends an element to the ring buffer.
Appends an element to the ring buffer .
&mut self
elem
T