changeset 78:64de3fd37c35

Refactor users of LinesWriter to make use of new function names
author Lewin Bormann <lbo@spheniscida.de>
date Sun, 07 Feb 2016 09:38:34 +0000
parents 72076befe75f
children 40a552fe2dbc
files src/formats/lines.rs src/map.rs src/shard_merge.rs
diffstat 3 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/formats/lines.rs	Sun Feb 07 09:33:06 2016 +0000
+++ b/src/formats/lines.rs	Sun Feb 07 09:38:34 2016 +0000
@@ -76,11 +76,14 @@
     file: W,
 }
 
-impl<W: io::Write> LinesWriter<W> {
+impl LinesWriter<fs::File> {
     pub fn new_to_file(path: &String) -> io::Result<LinesWriter<fs::File>> {
         let f = try!(fs::OpenOptions::new().write(true).create(true).truncate(true).open(path));
         Ok(LinesWriter { file: f })
     }
+}
+
+impl<W: io::Write> LinesWriter<W> {
     pub fn new_to_write(w: W) -> LinesWriter<W> {
         LinesWriter { file: w }
     }
@@ -165,7 +168,7 @@
     #[test]
     fn test_write_lines() {
         let line = String::from("abc def hello world");
-        let mut gen = lines::LinesSinkGenerator::new(&String::from("test_output_"));
+        let mut gen = lines::LinesSinkGenerator::new_to_files(&String::from("test_output_"));
         let mut f = gen.new_output(&String::from("1"));
 
         for _ in 0..10 {
--- a/src/map.rs	Sun Feb 07 09:33:06 2016 +0000
+++ b/src/map.rs	Sun Feb 07 09:38:34 2016 +0000
@@ -184,7 +184,7 @@
 
 
     fn get_output() -> LinesSinkGenerator {
-        LinesSinkGenerator::new(&String::from("test_map_"))
+        LinesSinkGenerator::new_to_files(&String::from("test_map_"))
     }
 
     #[test]
--- a/src/shard_merge.rs	Sun Feb 07 09:33:06 2016 +0000
+++ b/src/shard_merge.rs	Sun Feb 07 09:38:34 2016 +0000
@@ -224,9 +224,10 @@
     }
 
     use formats::lines;
+    use sort;
     use std::fmt;
+    use std::fs;
     use std::io::Write;
-    use sort;
 
     // Slow test!
     // #[test]