Move get_impl to crate.

This commit is contained in:
2018-12-09 10:49:04 +01:00
parent 1d5869af70
commit e101dbd58c
2 changed files with 30 additions and 30 deletions

View File

@@ -12,3 +12,32 @@ pub mod day06;
pub mod day07;
pub mod day08;
pub mod day09;
pub fn get_impl(day: u32) -> Box<common::Solution> {
match day {
1 => Box::new(day01::Day01::new()),
2 => Box::new(day02::Day02::new()),
3 => Box::new(day03::Day03::new()),
4 => Box::new(day04::Day04::new()),
5 => Box::new(day05::Day05::new()),
6 => Box::new(day06::Day06::new()),
7 => Box::new(day07::Day07::new()),
8 => Box::new(day08::Day08::new()),
9 => Box::new(day09::Day09::new()),
val => panic!("Unimplemented day {}", val),
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_get_impl() {
// Verify that we can load all days
let last_implemented = 8;
for d in 1..=last_implemented {
get_impl(d);
}
}
}

View File

@@ -6,25 +6,10 @@ use std::fs;
use std::io;
use std::time::Instant;
use aoc_2018::*;
use aoc_2018::get_impl;
use clap::Arg;
fn get_impl(day: u32) -> Box<common::Solution> {
match day {
1 => Box::new(day01::Day01::new()),
2 => Box::new(day02::Day02::new()),
3 => Box::new(day03::Day03::new()),
4 => Box::new(day04::Day04::new()),
5 => Box::new(day05::Day05::new()),
6 => Box::new(day06::Day06::new()),
7 => Box::new(day07::Day07::new()),
8 => Box::new(day08::Day08::new()),
9 => Box::new(day09::Day09::new()),
val => panic!("Unimplemented day {}", val),
}
}
fn main() {
let matches = app_from_crate!()
.arg(Arg::with_name("day")
@@ -64,17 +49,3 @@ fn main() {
}
println!("{}", result);
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_get_impl() {
// Verify that we can load all days
let last_implemented = 8;
for d in 1..=last_implemented {
get_impl(d);
}
}
}