Function tmx_utils::string_ext::read_string
source · pub fn read_string<R>(reader: R) -> Result<String, Error>where
R: BufRead,Expand description
Reads a line from a reader and trims it. Returns io errors or an error if the line is empty.
Examples
let e = read_string(&mut std::io::stdin().lock()).err().unwrap();
assert!(e.kind() == std::io::ErrorKind::InvalidInput);use tmx_utils::test_utils::run_file_test;
use std::io::BufReader;
let path = "./read_string.txt";
let content = "input_string";
run_file_test(
|f| {
assert_eq!(
read_string(BufReader::new(f)).unwrap(),
content
);
},
path, content,
);