diff --git a/day-4/src/main.rs b/day-4/src/main.rs index 1e5dfd9..7994ff9 100644 --- a/day-4/src/main.rs +++ b/day-4/src/main.rs @@ -17,16 +17,14 @@ fn parse_passports(input: &str) -> Result<Vec<HashMap<&str, &str>>, &str> { .trim() .split(|c| c == ' ' || c == '\n') .map(|field| { - let split = field - .find(':') - .ok_or("Invalid passport entry; no separator")?; + let split = field.find(':').ok_or("Invalid passport entry; no separator")?; let item = field.split_at(split); let key = item.0; let value = item .1 .strip_prefix(":") - .expect("We've already checked the separator exists"); + .ok_or("Invalid entry; value too short")?; Ok((key, value)) })