Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clippy::iter_with_drain suggests using .into_iter() instead of .drain(..) #6483

Closed
targrub opened this issue Nov 5, 2022 · 0 comments
Closed
Labels
C-Code-Quality A section of code that is hard to understand or change D-Trivial Nice and easy! A great choice to get started with Bevy

Comments

@targrub
Copy link
Contributor

targrub commented Nov 5, 2022

Bevy version

c019a60

What you did

Ran cargo clippy --workspace --all-targets --all-features -- -Aclippy::type_complexity -Wclippy::nursery -Aclippy::use_self -Aclippy::missing_const_for_fn -Aclippy::redundant_pub_crate -Aclippy::cognitive_complexity -Aclippy::branches_sharing_code -Aclippy::option_if_let_else -Aclippy::useless_let_if_seq -Aclippy::equatable_if_let -Aclippy::iter_on_single_items -Aclippy::iter_on_empty_collections -Aclippy::debug_assert_with_mut_call -Aclippy::type_repetition_in_bounds -Aclippy::trait_duplication_in_bounds -Aclippy::fallible_impl_from -Aclippy::future_not_send -Aclippy::imprecise_flops -Aclippy::suboptimal_flops -Wclippy::doc_markdown -Wclippy::redundant_else -Wclippy::match_same_arms -Wclippy::semicolon_if_nothing_returned -Wclippy::explicit_iter_loop -Wclippy::map_flatten -Dwarnings

What went wrong

error: `drain(..)` used on a `Vec`
   --> crates\bevy_ecs\src\schedule\ambiguity_detection.rs:239:10
    |
239 |         .drain(..)
    |          ^^^^^^^^^ help: try this: `into_iter()`
    |
    = note: `-D clippy::iter-with-drain` implied by `-D warnings`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_with_drain

error: `drain(..)` used on a `Vec`
   --> crates\bevy_ecs\src\schedule\ambiguity_detection.rs:240:29
    |
240 |         .zip(all_dependants.drain(..))
    |                             ^^^^^^^^^ help: try this: `into_iter()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_with_drain

error: `drain(..)` used on a `Vec`
   --> crates\bevy_ecs\src\schedule\ambiguity_detection.rs:253:47
    |
253 |     for (index_a, relations) in all_relations.drain(..).enumerate() {
    |                                               ^^^^^^^^^ help: try this: `into_iter()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_with_drain

error: `drain(..)` used on a `Vec`
   --> crates\bevy_ecs\src\schedule\stage.rs:312:31
    |
312 |         for system in systems.drain(..) {
    |                               ^^^^^^^^^ help: try this: `into_iter()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_with_drain

error: `drain(..)` used on a `Vec`
   --> crates\bevy_ecs\src\system\system_param.rs:211:10
    |
211 |         .drain(..)
    |          ^^^^^^^^^ help: try this: `into_iter()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_with_drain

Additional information

The documentation for this lint includes: ".into_iter() is simpler with better performance."

@targrub targrub added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Nov 5, 2022
@alice-i-cecile alice-i-cecile added C-Code-Quality A section of code that is hard to understand or change D-Trivial Nice and easy! A great choice to get started with Bevy and removed C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Nov 5, 2022
@bors bors bot closed this as completed in 694c980 Nov 6, 2022
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
# Objective

Fixes bevyengine#6483.

- Fix the [`clippy::iter_with_drain`](https://rust-lang.github.io/rust-clippy/master/index.html#iter_with_drain) warnings
- From the docs: "`.into_iter()` is simpler with better performance"

## Solution

- Replace `.drain(..)` for `Vec` with `.into_iter()`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Code-Quality A section of code that is hard to understand or change D-Trivial Nice and easy! A great choice to get started with Bevy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants