2021: day02: use split_once

This commit is contained in:
Antoine Martin 2021-12-03 17:34:28 +01:00
parent e8a36de2b4
commit ebc5fe5425

View file

@ -69,10 +69,7 @@ impl std::str::FromStr for Command {
type Err = anyhow::Error;
fn from_str(s: &str) -> Result<Self> {
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()?;