1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
use Write;
use void::Void;

/// Silently drops everything that is written to it.
pub struct Sink;

impl Write for Sink {
    type WriteError = Void;
    type FlushError = Void;
    
    fn write(&mut self, buf: &[u8]) -> Result<usize, Self::WriteError> {
        Ok(buf.len())
    }

    fn flush(&mut self) -> Result<(), Self::FlushError> {
        Ok(())
    }

    fn size_hint(&mut self, _bytes: usize) {}
}