Move Day trait into its own file
change
commit fcd7f65d715b947cfd5f55d6ffc5a6721785f1fc
author Alpha Chen <alpha.chen@gmail.com>
date
parent 7420c8a9
diff --git a/rust/src/day.rs b/rust/src/day.rs
new file mode 100644
index 0000000..9e3439a
--- /dev/null
+++ b/rust/src/day.rs
@@ -0,0 +1,6 @@
+use std::io;
+
+pub trait Day {
+    fn new(String) -> Self;
+    fn solve(self) -> io::Result<i32>;
+}
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
index 378c1e1..0d90e1b 100644
--- a/rust/src/lib.rs
+++ b/rust/src/lib.rs
@@ -1,21 +1,20 @@
-use std::io::Error;
+use std::io;
 use std::str::Chars;
 
-pub trait Day {
-    fn new(String) -> Self;
-    fn solve(self) -> Result<i32, Error>;
-}
+pub use day::Day;
+
+mod day;
 
 pub struct Day01 {
     input: String,
 }
 
-impl Day for Day01 {
+impl day::Day for Day01 {
     fn new(input: String) -> Day01 {
         Day01 { input: input }
     }
 
-    fn solve(self) -> Result<i32, Error> {
+    fn solve(self) -> io::Result<i32> {
         let elevator = Elevator::new(self.input);
         Ok(1 + elevator.run().position(|f| f == -1).unwrap_or(0) as i32)
     }