/// Removes at most first `count` bytes from the ring buffer and writes them into
/// a [`Write`](https://doc.rust-lang.org/std/io/trait.Write.html) instance.
/// If `count` is `None` then as much as possible bytes will be written.
Removes at most first `count` bytes from the ring buffer and writes them into
a [`Write`] instance.
If `count` is `None` then as much as possible bytes will be written.
Removes at most first ` count ` bytes from the ring buffer and writes them into a [ ` Write ` ] instance . If ` count ` is ` None ` then as much as possible bytes will be written .
pub fn write_into(&mut self, writer: &mut dyn Write, count: Option<usize>)
    -> Result<usize, WriteIntoError> {
        let pop_fn = |left: &mut [u8], _right: &mut [u8]|
        -> Result<(usize, ()), io::Error> {
            let left = match count {
                Some(c) => {
                    if c < left.len() {
                        &mut left[0..c]
                    } else {
                        left
                    }
                },
                None => left,
            };
            writer.write(left).and_then(|n| {
                if n <= left.len() {
                    Ok((n, ()))
                } else {
                    Err(io::Error::new(
                        io::ErrorKind::InvalidInput,
                        "Write operation returned invalid number",
                    ))
                }
            })
        };
        match unsafe { self.pop_access(pop_fn) } {
            Ok(res) => match res {
                Ok((n, ())) => Ok(n),
                Err(e) => Err(WriteIntoError::Write(e)),
            },
            Err(e) => match e {
                PopAccessError::Empty => Err(WriteIntoError::RbEmpty),
                PopAccessError::BadLen => unreachable!(),
            }
        }
    }
pub fn write_into ( & mut self , writer : & mut dyn Write , count : Option < usize > ) -> Result < usize , WriteIntoError > { let pop_fn = | left : & mut [ u8 ] , _right : & mut [ u8 ] | -> Result < ( usize , ( ) ) , io :: Error > { let left = match count { Some ( c ) => { if c < left . len ( ) { & mut left [ 0 .. c ] } else { left } } , None => left , } ; writer . write ( left ) . and_then ( | n | { if n <= left . len ( ) { Ok ( ( n , ( ) ) ) } else { Err ( io :: Error :: new ( io :: ErrorKind :: InvalidInput , " " , ) ) } } ) } ; match unsafe { self . pop_access ( pop_fn ) } { Ok ( res ) => match res { Ok ( ( n , ( ) ) ) => Ok ( n ) , Err ( e ) => Err ( WriteIntoError :: Write ( e ) ) , } , Err ( e ) => match e { PopAccessError :: Empty => Err ( WriteIntoError :: RbEmpty ) , PopAccessError :: BadLen => unreachable ! ( ) , } } }
Removes at most first `count` bytes from the ring buffer and writes them into
a [`Write`](https://doc.rust-lang.org/std/io/trait.Write.html) instance.
Removes at most first ` count ` bytes from the ring buffer and writes them into a [ ` Write ` ] ( https : // doc . rust - lang . org / std / io / trait . Write . html ) instance .
&mut self
writer
&mut dyn Write
count
Option<usize>