1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
use std::io::Result;

pub fn stdinix<F>(mut cl: F) -> Result<()>
where
    F: FnMut(&str) -> Result<()>,
{
    let mut buf = String::new();
    while let Ok(true) = {
        buf.clear();
        std::io::stdin().read_line(&mut buf).map(|l| l > 0)
    } {
        cl(&buf)?;
    }

    Ok(())
}