use anyhow::Result; use std::io::{BufReader, self, Read}; // this will read and validate input from stdin // TODO: make as iterator, avoid loading all stdin to memroy pub fn read_stdin() -> Result> { let mut r = BufReader::new(io::stdin()); let mut buf = Box::::default(); r.read_to_string(&mut buf)?; Ok(buf) } // //NOTE: need deeper understanding of difference with prev implementation // pub fn read_stdin() -> Result> { // Ok(Box::new(BufReader::new(io::stdin()))) // } #[cfg(test)] mod tests { // #[test] // fn read_stdin() { // panic!() // } }