Rust

Rust

Made by DeepSource

Found call to .trim() followed by .split_whitespace() RS-P1005

Performance
Minor

.split_whitespace() produces an iterator with preceding and trailing whitespace removed. Thus, s.trim().split_whitespace() is equivalent to just s.split_whitespace().

Bad practice

let mut iter = " A B C ".trim().split_whitespace();

assert_eq!(Some("A"), iter.next());
assert_eq!(Some("B"), iter.next());
assert_eq!(Some("C"), iter.next());

assert_eq!(None, iter.next());

Recommended

// The call to `.trim()` is redundant!
let mut iter = " A B C ".split_whitespace();

assert_eq!(Some("A"), iter.next());
assert_eq!(Some("B"), iter.next());
assert_eq!(Some("C"), iter.next());

assert_eq!(None, iter.next());