From f093d4bc872b6a04ac00e54204c82b56cd5ee157 Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Sun, 6 Dec 2020 02:18:10 -0800 Subject: trim every line automatically --- lib/src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 5f87317..d09e357 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -27,7 +27,14 @@ pub fn read_lines_file(filename: &str) -> Result> { } let mut line_copy = String::new(); - line_copy.push_str(buffer.trim()); + match buffer.strip_suffix("\n") { + Some(stripped) => { + line_copy.push_str(stripped); + } + None => { + line_copy.push_str(&buffer); + } + } input.push(line_copy); buffer.clear(); -- cgit 1.4.1