if stdin().is_terminal() {
let mut buf_in = BufReader::new(stdin());
let separator = b'\n';
println!("Start terminal input for bstr for_byte_record_with_terminator\nTry ^D - it will not exit right away on the first ^D");
let _result_bstr = buf_in.for_byte_record_with_terminator(separator, |_line| {
// do something with each line
Ok(true)
})?;
println!("Done");
println!("Start terminal input for std io, like split, read_until, etc\nTry ^D");
let _result_std = buf_in.split(separator).for_each(|_line| {
// do something with each line
});
println!("Done");
}
Comparing to similar functions from std::io, which do exit on the first Control-D right away in the terminal.
This limits usefulness of bstr crate for developing command line utilities that need to process all stdin variants (piped, redirected from file, terminal)