From 24d37cdf04fb6fc241330c9274fa635b12d92abd Mon Sep 17 00:00:00 2001 From: Jim Infield Date: Mon, 2 Aug 2021 10:06:07 -0500 Subject: [PATCH] cargo clippy cleanup --- src/main.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index c0d3f35..4f6dc17 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ fn main() { - println!(""); + println!(); let strs = vec!["is2 Thi1s T4est 3a"]; @@ -7,7 +7,7 @@ fn main() { println!("{} -> {}", str, order(str)); } - println!(""); + println!(); } fn order(sentence: &str) -> String { @@ -16,15 +16,18 @@ fn order(sentence: &str) -> String { for word in sentence.split_whitespace() { let n = word.matches(char::is_numeric).collect::>()[0]; - print!("{:?}\t{:?}\n", n, word); + println!("{:?}\t{:?}", n, word); } - println!(""); + println!(); words = sentence.split_ascii_whitespace() .map(|s| format!("{}{}", s.matches(char::is_numeric).collect::>()[0],s)) .collect(); + words.sort(); - words.iter().map(|w| w.trim_start_matches(char::is_numeric)).collect::>().join(" ") + words.iter().map(|w| &w[1..]) + .collect::>() + .join(" ") }