shh 1.0.1

Silence stderr and stdout, optionally rerouting it.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
extern crate shh;
use std::io::Read;

fn main() {
    // if this blocks then it is failing.
    println!("this will be printed");
    let mut shh = shh::stdout().unwrap();
    let mut s = String::new();
    assert_eq!(shh.read_to_string(&mut s).unwrap(), 0); // should exit immediately and return empty string
    assert_eq!(&s, "");

    // if this blocks then it is failing.
    eprintln!("this will be printed");
    let mut shh = shh::stderr().unwrap();
    let mut s = String::new();
    assert_eq!(shh.read_to_string(&mut s).unwrap(), 0); // should exit immediately and return empty string
    assert_eq!(&s, "");
}