RS.CLIPPY.ITER_WITH_DRAIN
Replace `.drain(..)` with `.into_iter()`
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: iter_with_drain. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for usage of .drain(..) on Vec and VecDeque for iteration.
Why is this bad?
.into_iter() is simpler with better performance.
Example
let mut foo = vec![0, 1, 2, 3];
let bar: HashSet<usize> = foo.drain(..).collect();
Use instead:
let foo = vec![0, 1, 2, 3];
let bar: HashSet<usize> = foo.into_iter().collect();