diff --git a/src/day07/main.rs b/src/day07/main.rs index d7ec88f..4337768 100644 --- a/src/day07/main.rs +++ b/src/day07/main.rs @@ -76,8 +76,8 @@ impl<'a> BagRules<'a> { fn parse_bag_rule_line(line: &'a str) -> (Bag<'a>, Vec>) { let mut splitted = line.splitn(2, " bags contain "); - let key = splitted.next().expect("invalid bag rule line: missing key"); - let values = splitted.next().expect("invalid bag rule line: missing value"); + let key = splitted.next().unwrap(); + let values = splitted.next().unwrap(); if values == "no other bags." { return (key, vec![]); @@ -85,7 +85,7 @@ impl<'a> BagRules<'a> { let values: Vec<&str> = values .strip_suffix(".") - .expect("invalid bag rule line: not terminated with `.`") + .unwrap() .split(',') .flat_map(BagRules::parse_bag_content) .collect(); @@ -99,7 +99,7 @@ impl<'a> BagRules<'a> { let bag = bag .strip_suffix(" bags") .or(bag.strip_suffix(" bag")) - .expect("invalid bag content: no bag(s) suffix"); + .unwrap(); let count = count.trim().parse::().unwrap(); vec![bag.trim(); count] }