diff --git a/2018/src/common.rs b/2018/src/common.rs index 880400f..ce2ea2f 100644 --- a/2018/src/common.rs +++ b/2018/src/common.rs @@ -35,10 +35,10 @@ pub fn prime_sieve(dest: &mut[bool]) { /// be easily run from the main program. pub trait Solution { /// Solve the first part of the day - fn part1(&mut self, input: Box); + fn part1(&mut self, input: &mut io::Read) -> String; /// Solve the second part of the day - fn part2(&mut self, input: Box); + fn part2(&mut self, input: &mut io::Read) -> String; } #[cfg(test)] diff --git a/2018/src/day1.rs b/2018/src/day1.rs index bf413b9..fdaff75 100644 --- a/2018/src/day1.rs +++ b/2018/src/day1.rs @@ -11,11 +11,11 @@ impl Day1 { } impl common::Solution for Day1 { - fn part1(&mut self, input: Box) { - println!("Not implemented"); + fn part1(&mut self, input: &mut io::Read) -> String { + panic!("Not implemented"); } - fn part2(&mut self, input: Box) { - println!("Not implemented"); + fn part2(&mut self, input: &mut io::Read) -> String { + panic!("Not implemented"); } } diff --git a/2018/src/main.rs b/2018/src/main.rs index 5e373e6..1c38dc1 100644 --- a/2018/src/main.rs +++ b/2018/src/main.rs @@ -38,15 +38,15 @@ fn main() { let day: i32 = (&matches.value_of("day").unwrap()).parse() .expect("Invalid int"); let mut implementation = get_impl(day); - let data: Box = match matches.value_of("input") { + let mut data: Box = match matches.value_of("input") { Some(filename) => { Box::new(fs::File::open(filename).unwrap()) } None => { Box::new(io::stdin()) } }; if matches.is_present("part2") { - implementation.part2(data) + println!("{}", implementation.part2(&mut data)); } else { - implementation.part1(data) + println!("{}", implementation.part1(&mut data)); } }