grabinput 0.2.1

Unixy lib for reading from a file or from stdin
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::io::{BufRead, Read};

#[allow(unused)]
pub fn next_line<T: BufRead>(reader: &mut T) -> Option<String> {
    let mut buf = String::new();
    match reader.read_line(&mut buf) {
        Ok(0) | Err(_) => None,
        Ok(_) => Some(buf),
    }
}

#[allow(unused)]
pub fn whole_stream<T: Read>(reader: &mut T) -> String {
    let mut buf = String::new();
    reader.read_to_string(&mut buf);
    buf
}