Closed

Description
What it does
Warns about calling str::trim
(and variants) before str::split_whitespace
(and variants). split_whitespace
already ignores leading and trailing whitespace.
These two lines produce the same output:
println!("{:?}", " A B C ".trim().split_whitespace().collect::<Vec<_>>());
println!("{:?}", " A B C ".split_whitespace().collect::<Vec<_>>());
which is
["A", "B", "C"]
["A", "B", "C"]
Lint Name
trim_split_whitespace
Category
pedantic
Advantage
- The
trim
call is needless - The developer might not realize that
split_whitespace
works this way
Drawbacks
No response
Example
" A B C ".trim().split_whitespace()
Could be written as:
" A B C ".split_whitespace()