summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@gmail.com>2020-12-06 02:18:10 -0800
committerIrene Knapp <ireneista@gmail.com>2020-12-06 02:18:10 -0800
commitf093d4bc872b6a04ac00e54204c82b56cd5ee157 (patch)
treef389eebf43bef42fdb4b061e75a7a53ea2551e8b /lib
parent08491f4e7e21ca2e59aaeb90aee0982add800859 (diff)
trim every line automatically
Diffstat (limited to 'lib')
-rw-r--r--lib/src/lib.rs9
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();