Open
Description
openedon Oct 22, 2024
What it does
Suggest to replace vec.drain(x..)
to vec.truncate(x)
since it is simpler and cleaner.
Advantage
- It is shorter and cleaner
Drawbacks
No response
Example
fn main() {
let mut x = vec![1, 2, 3, 4, 5, 6];
x.drain(1..);
}
Could be written as:
fn main() {
let mut x = vec![1, 2, 3, 4, 5, 6];
x.truncate(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment