.trim()
followed by .split_whitespace()
RS-P1005.split_whitespace()
produces an iterator with preceding and trailing
whitespace removed. Thus, s.trim().split_whitespace()
is equivalent to just
s.split_whitespace()
.
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());
// 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());