diff --git a/src/parsing.rs b/src/parsing.rs index 6ddd29c..a125354 100644 --- a/src/parsing.rs +++ b/src/parsing.rs @@ -42,12 +42,11 @@ pub fn parse_n, const N: usize>( parser: &dyn Fn(&mut P) -> Option, separator: &dyn Fn(&mut P) -> bool, ) -> Option<[T; N]> { - let elements: Vec = tokens.sep_by(parser, separator).collect(); - if elements.len() != 10 { - None - } else { - Some(elements.try_into().unwrap()) - } + tokens + .sep_by(parser, separator) + .collect::>() + .try_into() + .ok() } #[cfg(test)]