Function null

Source
pub fn null() -> Result<File>
Expand description

Returns a file that can be written to. The file discards all bytes written to it.

let mut f = null()?;
f.write_all(b"hello world")?;

It can be used to dicard all the data written to stdout

let _guard = null()?.override_stdout();
println!("hello world!"); // this will never print