-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
A-lintArea: New lintsArea: New lints
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
trimcall is needless - The developer might not realize that
split_whitespaceworks this way
Drawbacks
No response
Example
" A B C ".trim().split_whitespace()Could be written as:
" A B C ".split_whitespace()bhgomes, FoseFx and tchajed
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lints