From 3ebcf0fbeb84e7dd77115e61a86f5933e7e2ca91 Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Fri, 1 Jan 2016 15:29:33 -0800 Subject: [PATCH] [rust] Don't borrow inputs for day solvers --- rust/src/day.rs | 2 +- rust/src/day_01.rs | 4 ++-- rust/src/day_02.rs | 2 +- rust/src/day_03.rs | 4 ++-- rust/src/main.rs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) 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; } 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 { 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::>() } } 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 { 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 { fn main() { let input = read_input("day_03").unwrap(); - let day = Day03::new(&input); + let day = Day03::new(input); println!("{}", day.solve().unwrap()); }