mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
Move get_impl to crate.
This commit is contained in:
@@ -12,3 +12,32 @@ pub mod day06;
|
|||||||
pub mod day07;
|
pub mod day07;
|
||||||
pub mod day08;
|
pub mod day08;
|
||||||
pub mod day09;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,25 +6,10 @@ use std::fs;
|
|||||||
use std::io;
|
use std::io;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
use aoc_2018::*;
|
use aoc_2018::get_impl;
|
||||||
|
|
||||||
use clap::Arg;
|
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() {
|
fn main() {
|
||||||
let matches = app_from_crate!()
|
let matches = app_from_crate!()
|
||||||
.arg(Arg::with_name("day")
|
.arg(Arg::with_name("day")
|
||||||
@@ -64,17 +49,3 @@ fn main() {
|
|||||||
}
|
}
|
||||||
println!("{}", result);
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user