diff --git a/2023/day7/src/main.rs b/2023/day7/src/main.rs index 66c6a8b..df31a83 100644 --- a/2023/day7/src/main.rs +++ b/2023/day7/src/main.rs @@ -33,7 +33,7 @@ enum HandType { trait Parse { type Out; - fn parse(s: &str) -> IResult<&str, Box>; + fn parse(s: &str) -> IResult<&str, Self::Out>; } #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)] @@ -72,11 +72,11 @@ enum CardWithJoker { impl Parse for CardWithoutJoker { type Out = Self; - fn parse(s: &str) -> IResult<&str, Box> { + fn parse(s: &str) -> IResult<&str, Self> { let (rest, c) = anychar(s)?; Ok(( rest, - Box::new(match c { + match c { '2' => Self::Two, '3' => Self::Three, '4' => Self::Four, @@ -96,18 +96,18 @@ impl Parse for CardWithoutJoker { nom::error::ErrorKind::Char, ))) } - }), + }, )) } } impl Parse for CardWithJoker { type Out = Self; - fn parse(s: &str) -> IResult<&str, Box> { + fn parse(s: &str) -> IResult<&str, Self> { let (rest, c) = anychar(s)?; Ok(( rest, - Box::new(match c { + match c { '2' => Self::Two, '3' => Self::Three, '4' => Self::Four, @@ -127,7 +127,7 @@ impl Parse for CardWithJoker { nom::error::ErrorKind::Char, ))) } - }), + }, )) } } @@ -191,7 +191,6 @@ trait ParseHand { Box::new(Self::Out::from_vec( cards .into_iter() - .map(|card| *card) .collect::::CardType>>(), )), ))