summaryrefslogtreecommitdiffstats
path: root/src/2020/2/mod.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2020-12-04 16:10:18 -0500
committerJesse Luehrs <doy@tozt.net>2020-12-04 16:10:18 -0500
commit7543903709a1c7e56be6260befb117baea833c0a (patch)
treef27178335b2e7cebc33f7d7c3da383e55e02f233 /src/2020/2/mod.rs
parent29b1679b024f4f56d43b1646d6fa5d301994f6f4 (diff)
downloadadvent-of-code-7543903709a1c7e56be6260befb117baea833c0a.tar.gz
advent-of-code-7543903709a1c7e56be6260befb117baea833c0a.zip
refactor
Diffstat (limited to 'src/2020/2/mod.rs')
-rw-r--r--src/2020/2/mod.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/2020/2/mod.rs b/src/2020/2/mod.rs
index a81665b..1026b03 100644
--- a/src/2020/2/mod.rs
+++ b/src/2020/2/mod.rs
@@ -1,4 +1,5 @@
use anyhow::Context as _;
+use std::convert::TryInto as _;
use std::io::BufRead as _;
struct Line {
@@ -51,18 +52,16 @@ impl Line {
}
}
-pub fn part1() -> anyhow::Result<()> {
+pub fn part1() -> anyhow::Result<i64> {
let lines = read_lines()?;
let count = lines.iter().filter(|l| l.valid_part_1()).count();
- println!("{}", count);
- Ok(())
+ Ok(count.try_into()?)
}
-pub fn part2() -> anyhow::Result<()> {
+pub fn part2() -> anyhow::Result<i64> {
let lines = read_lines()?;
let count = lines.iter().filter(|l| l.valid_part_2()).count();
- println!("{}", count);
- Ok(())
+ Ok(count.try_into()?)
}
fn read_lines() -> anyhow::Result<Vec<Line>> {