[rust] Don't borrow inputs for day solvers
change
commit 3ebcf0fbeb84e7dd77115e61a86f5933e7e2ca91
author Alpha Chen <alpha.chen@gmail.com>
date
parent bae1972f
diff --git a/rust/src/day.rs b/rust/src/day.rs
index 68e64d9..8821ee2 100644
--- a/rust/src/day.rs
+++ b/rust/src/day.rs
@@ -1,6 +1,6 @@
 use std::io;
 
 pub trait Day {
-    fn new(&String) -> Self;
+    fn new(String) -> Self;
     fn solve(&self) -> io::Result<i32>;
 }
diff --git a/rust/src/day_01.rs b/rust/src/day_01.rs
index a2be84a..5bd6634 100644
--- a/rust/src/day_01.rs
+++ b/rust/src/day_01.rs
@@ -8,8 +8,8 @@ pub struct Day01 {
 }
 
 impl Day for Day01 {
-    fn new(input: &String) -> Day01 {
-        Day01 { input: input.clone() }
+    fn new(input: String) -> Day01 {
+        Day01 { input: input }
     }
 
     fn solve(&self) -> io::Result<i32> {
diff --git a/rust/src/day_02.rs b/rust/src/day_02.rs
index a694858..106f87d 100644
--- a/rust/src/day_02.rs
+++ b/rust/src/day_02.rs
@@ -7,7 +7,7 @@ pub struct Day02 {
 }
 
 impl Day for Day02 {
-    fn new(input: &String) -> Day02 {
+    fn new(input: String) -> Day02 {
         let presents = input.split("\n").map(|line| Present::new(line));
         Day02 { presents: presents.collect::<Vec<Present>>() }
     }
diff --git a/rust/src/day_03.rs b/rust/src/day_03.rs
index 8c4baa8..8dbe942 100644
--- a/rust/src/day_03.rs
+++ b/rust/src/day_03.rs
@@ -12,8 +12,8 @@ pub struct Day03 {
 }
 
 impl Day for Day03 {
-    fn new(input: &String) -> Day03 {
-        Day03 { directions: input.clone() }
+    fn new(input: String) -> Day03 {
+        Day03 { directions: input }
     }
 
     fn solve(&self) -> io::Result<i32> {
diff --git a/rust/src/main.rs b/rust/src/main.rs
index 804f92c..3d7bd5e 100644
--- a/rust/src/main.rs
+++ b/rust/src/main.rs
@@ -20,6 +20,6 @@ fn read_input(filename: &str) -> Result<String, io::Error> {
 
 fn main() {
     let input = read_input("day_03").unwrap();
-    let day = Day03::new(&input);
+    let day = Day03::new(input);
     println!("{}", day.solve().unwrap());
 }