diff --git a/examples/example_utils.rs b/examples/example_utils.rs index b7168f77..3f1d9886 100644 --- a/examples/example_utils.rs +++ b/examples/example_utils.rs @@ -1,4 +1,4 @@ -use std::{env, fs, io}; +use std::{env, fmt::Write, fs, io}; #[allow(dead_code)] pub fn print_with_lines(content: &str) { println!( @@ -6,8 +6,10 @@ pub fn print_with_lines(content: &str) { content .lines() .enumerate() - .map(|(num, content)| format!("{:4}. {}\n", num + 1, content)) - .collect::() + .fold(String::new(), |mut out, (num, content)| { + let _ = writeln!(out, "{:4}. {}", num + 1, content); + out + }) ); } diff --git a/src/parser/components.rs b/src/parser/components.rs index 5ce41627..a29dc6aa 100644 --- a/src/parser/components.rs +++ b/src/parser/components.rs @@ -287,11 +287,9 @@ pub fn inner_component<'a, E: ParseError<&'a str> + ContextError<&'a str>>( input: &'a str, ) -> IResult<&'a str, InnerComponent, E> { match component::<(_, _)>(input) { - Ok(result) => { - return Ok((result.0, InnerComponent::from(result.1))); - } + Ok(result) => Ok((result.0, InnerComponent::from(result.1))), Err(_e) => todo!(), - }; + } } #[test]