|
https://rust-lang.github.io/rust-clippy/rust-1.91.0/#iter_with_drain Hey i was wondering about this lint. If i understand correctly drain does not deallocate the allocation of a Vec and keeps the capacity unttouched. I have a hotloop in my program i use to keep track of things i want to cleanup and then i drain the vec to do the cleanup but i dont want to use into_iter() as this drops the vec altogether. I feel like there is genuine use cases for using drain as iteration like in this example. I would like to hear some counter arguments on why this lint was designed like such and why i might be wrong. |
Replies: 1 comment
|
This lint is in the But also note that not every Clippy lint applies to every project. You might have use cases where you actually want to go against a Clippy lint. Then it is recommended to annotate that code with a #[expect(clippy::lint, reason = "this is intentional, because [...]")] |
This lint is in the
nurserygroup, which means that it is disabled-by-default, because it has problems. What you encounter might be a bug.But also note that not every Clippy lint applies to every project. You might have use cases where you actually want to go against a Clippy lint. Then it is recommended to annotate that code with a
#[expect(clippy::lint, reason = "this is intentional, because [...]")]