From 70fcbd804a8418d5f9acd4f3839df414816fc98f Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Wed, 5 Dec 2018 12:40:22 -0800 Subject: [PATCH] [2018][rust][2] move from lib to bin --- 2018/rust/src/{ => bin}/day_02.rs | 15 ++++++++++++++- 2018/rust/src/main.rs | 9 +-------- 2 files changed, 15 insertions(+), 9 deletions(-) rename 2018/rust/src/{ => bin}/day_02.rs (83%) diff --git a/2018/rust/src/day_02.rs b/2018/rust/src/bin/day_02.rs similarity index 83% rename from 2018/rust/src/day_02.rs rename to 2018/rust/src/bin/day_02.rs index d24771d..414573c 100644 --- a/2018/rust/src/day_02.rs +++ b/2018/rust/src/bin/day_02.rs @@ -1,4 +1,17 @@ -pub fn solve(input: &str) -> String { +use std::error::Error; +use std::io::{self, Read}; + +fn main() -> Result<(), Box> { + let mut input = String::new(); + io::stdin().read_to_string(&mut input)?; + + let output = solve(&input); + println!("{}", output); + + Ok(()) +} + +fn solve(input: &str) -> String { let box_ids: Vec<_> = input.lines().map(BoxId::new).collect(); let two_count = box_ids.iter().filter(|&x| x.is_two()).count(); diff --git a/2018/rust/src/main.rs b/2018/rust/src/main.rs index 0135cf4..00bcf0b 100644 --- a/2018/rust/src/main.rs +++ b/2018/rust/src/main.rs @@ -1,12 +1,5 @@ use std::io::{self, Read}; mod day_01; -mod day_02; -fn main() { - let mut input = String::new(); - io::stdin().read_to_string(&mut input).unwrap(); - - let output = day_02::solve(&input); - println!("{}", output); -} +fn main() {}