diff --git a/aoc2021/src/day02.rs b/aoc2021/src/day02.rs index 2bfc9c7..a65b4e1 100644 --- a/aoc2021/src/day02.rs +++ b/aoc2021/src/day02.rs @@ -69,10 +69,7 @@ impl std::str::FromStr for Command { type Err = anyhow::Error; fn from_str(s: &str) -> Result { - let mut split = s.split(' '); - - let word = split.next().context("couldn't find word in command")?; - let number = split.next().context("couldn't find number in command")?; + let (word, number) = s.split_once(' ').context("couldn't split command")?; let number = number.parse()?;