What it does
Checks for .truncate(0) calls on standard library types like Vec, VecDeque, String, and OsString where it can be replaced with .clear().
Advantage
clear() expresses the intent better and is likely to be more efficient than truncate(0).
Drawbacks
No response
Example
let mut v = vec![1, 2, 3];
v.truncate(0);
Could be written as:
let mut v = vec![1, 2, 3];
v.clear();
Comparison with existing lints
No response
Additional Context
rust-lang/rust@9c59d04
What it does
Checks for
.truncate(0)calls on standard library types likeVec,VecDeque,String, andOsStringwhere it can be replaced with.clear().Advantage
clear()expresses the intent better and is likely to be more efficient thantruncate(0).Drawbacks
No response
Example
Could be written as:
Comparison with existing lints
No response
Additional Context
rust-lang/rust@9c59d04