diff options
author | Irene Knapp <ireneista@gmail.com> | 2020-12-06 02:18:10 -0800 |
---|---|---|
committer | Irene Knapp <ireneista@gmail.com> | 2020-12-06 02:18:10 -0800 |
commit | f093d4bc872b6a04ac00e54204c82b56cd5ee157 (patch) | |
tree | f389eebf43bef42fdb4b061e75a7a53ea2551e8b | |
parent | 08491f4e7e21ca2e59aaeb90aee0982add800859 (diff) |
trim every line automatically
-rw-r--r-- | lib/src/lib.rs | 9 |
1 files changed, 8 insertions, 1 deletions
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<Vec<String>> { } 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(); |