summary refs log tree commit diff
path: root/lib/src
diff options
context:
space:
mode:
Diffstat (limited to 'lib/src')
-rw-r--r--lib/src/lib.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/src/lib.rs b/lib/src/lib.rs
index 4b4b679..4913cbb 100644
--- a/lib/src/lib.rs
+++ b/lib/src/lib.rs
@@ -14,6 +14,29 @@ pub fn greeting() -> Result<()> {
   Ok(())
 }
 
+pub fn read_lines_file(filename: &str) -> Result<Vec<String>> {
+  let file = File::open(filename)?;
+  let mut reader = BufReader::new(file);
+  let mut buffer = String::new();
+
+  let mut input: Vec<String> = Vec::new();
+  loop {
+    reader.read_line(&mut buffer)?;
+    if buffer.len() == 0 {
+      break;
+    }
+
+    let mut line_copy = String::new();
+    line_copy.push_str(buffer.trim());
+    input.push(line_copy);
+
+    buffer.clear();
+  }
+
+  Ok(input)
+}
+
+
 pub fn read_int_file(filename: &str) -> Result<Vec<i64>> {
   let file = File::open(filename)?;
   let mut reader = BufReader::new(file);