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

[Merged by Bors] - Fix clippy::iter_with_drain #6485

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/bevy_asset/src/loader.rs
Expand Up @@ -86,8 +86,8 @@ impl<T: Asset> LoadedAsset<T> {

/// Adds dependencies on other assets at the provided paths.
#[must_use]
pub fn with_dependencies(mut self, mut asset_paths: Vec<AssetPath<'static>>) -> Self {
for asset_path in asset_paths.drain(..) {
pub fn with_dependencies(mut self, asset_paths: Vec<AssetPath<'static>>) -> Self {
for asset_path in asset_paths.into_iter() {
self.add_dependency(asset_path);
}
self
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_ecs/src/schedule/ambiguity_detection.rs
Expand Up @@ -235,9 +235,9 @@ fn find_ambiguities(systems: &[SystemContainer]) -> Vec<(usize, usize, Vec<Compo
}
all_dependants[index] = dependants;
}
let mut all_relations = all_dependencies
.drain(..)
.zip(all_dependants.drain(..))
let all_relations = all_dependencies
.into_iter()
.zip(all_dependants.into_iter())
.enumerate()
.map(|(index, (dependencies, dependants))| {
let mut relations = FixedBitSet::with_capacity(systems.len());
Expand All @@ -250,7 +250,7 @@ fn find_ambiguities(systems: &[SystemContainer]) -> Vec<(usize, usize, Vec<Compo
let mut ambiguities = Vec::new();
let full_bitset: FixedBitSet = (0..systems.len()).collect();
let mut processed = FixedBitSet::with_capacity(systems.len());
for (index_a, relations) in all_relations.drain(..).enumerate() {
for (index_a, relations) in all_relations.into_iter().enumerate() {
// TODO: prove that `.take(index_a)` would be correct here, and uncomment it if so.
for index_b in full_bitset.difference(&relations)
// .take(index_a)
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/schedule/stage.rs
Expand Up @@ -309,7 +309,7 @@ impl SystemStage {
}
}
});
for system in systems.drain(..) {
for system in systems.into_iter() {
TimJentzsch marked this conversation as resolved.
Show resolved Hide resolved
self.add_system_inner(system, set_run_criteria_index);
}
self
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/system/system_param.rs
Expand Up @@ -203,12 +203,12 @@ fn assert_component_access_compatibility(
current: &FilteredAccess<ComponentId>,
world: &World,
) {
let mut conflicts = system_access.get_conflicts_single(current);
let conflicts = system_access.get_conflicts_single(current);
if conflicts.is_empty() {
return;
}
let conflicting_components = conflicts
.drain(..)
.into_iter()
.map(|component_id| world.components.get_info(component_id).unwrap().name())
.collect::<Vec<&str>>();
let accesses = conflicting_components.join(", ");
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_pbr/src/material.rs
Expand Up @@ -536,8 +536,8 @@ fn prepare_materials<M: Material>(
fallback_image: Res<FallbackImage>,
pipeline: Res<MaterialPipeline<M>>,
) {
let mut queued_assets = std::mem::take(&mut prepare_next_frame.assets);
for (handle, material) in queued_assets.drain(..) {
let queued_assets = std::mem::take(&mut prepare_next_frame.assets);
for (handle, material) in queued_assets.into_iter() {
TimJentzsch marked this conversation as resolved.
Show resolved Hide resolved
match prepare_material(
&material,
&render_device,
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_render/src/render_asset.rs
Expand Up @@ -186,8 +186,8 @@ fn prepare_assets<R: RenderAsset>(
param: StaticSystemParam<<R as RenderAsset>::Param>,
) {
let mut param = param.into_inner();
let mut queued_assets = std::mem::take(&mut prepare_next_frame.assets);
for (handle, extracted_asset) in queued_assets.drain(..) {
let queued_assets = std::mem::take(&mut prepare_next_frame.assets);
for (handle, extracted_asset) in queued_assets.into_iter() {
TimJentzsch marked this conversation as resolved.
Show resolved Hide resolved
match R::prepare_asset(extracted_asset, &mut param) {
Ok(prepared_asset) => {
render_assets.insert(handle, prepared_asset);
Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_render/src/render_phase/mod.rs
Expand Up @@ -35,8 +35,7 @@ impl<I: BatchedPhaseItem> RenderPhase<I> {
/// Batches the compatible [`BatchedPhaseItem`]s of this render phase
pub fn batch(&mut self) {
// TODO: this could be done in-place
let mut items = std::mem::take(&mut self.items);
let mut items = items.drain(..);
let mut items = std::mem::take(&mut self.items).into_iter();

self.items.reserve(items.len());

Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_sprite/src/mesh2d/material.rs
Expand Up @@ -471,8 +471,8 @@ fn prepare_materials_2d<M: Material2d>(
fallback_image: Res<FallbackImage>,
pipeline: Res<Material2dPipeline<M>>,
) {
let mut queued_assets = std::mem::take(&mut prepare_next_frame.assets);
for (handle, material) in queued_assets.drain(..) {
let queued_assets = std::mem::take(&mut prepare_next_frame.assets);
for (handle, material) in queued_assets.into_iter() {
TimJentzsch marked this conversation as resolved.
Show resolved Hide resolved
match prepare_material2d(
&material,
&render_device,
Expand Down