Fix clippy::let_and_return in bevy_ecs (#18481)

# Objective

- `clippy::let_and_return` fails in `bevy_ecs`

## Solution

- Fixed it!

## Testing

- CI
This commit is contained in:
Zachary Harrold 2025-03-22 22:48:40 +11:00 committed by GitHub
parent 72b4ed05c7
commit 2eb836abaf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 6 deletions

View File

@ -942,7 +942,7 @@ impl Archetypes {
let archetypes = &mut self.archetypes; let archetypes = &mut self.archetypes;
let archetype_component_count = &mut self.archetype_component_count; let archetype_component_count = &mut self.archetype_component_count;
let component_index = &mut self.by_component; let component_index = &mut self.by_component;
let archetype_id = *self *self
.by_components .by_components
.entry(archetype_identity) .entry(archetype_identity)
.or_insert_with_key(move |identity| { .or_insert_with_key(move |identity| {
@ -975,8 +975,7 @@ impl Archetypes {
.zip(sparse_set_archetype_components), .zip(sparse_set_archetype_components),
)); ));
id id
}); })
archetype_id
} }
/// Returns the number of components that are stored in archetypes. /// Returns the number of components that are stored in archetypes.

View File

@ -1585,7 +1585,7 @@ impl Bundles {
storages: &mut Storages, storages: &mut Storages,
) -> BundleId { ) -> BundleId {
let bundle_infos = &mut self.bundle_infos; let bundle_infos = &mut self.bundle_infos;
let id = *self.bundle_ids.entry(TypeId::of::<T>()).or_insert_with(|| { *self.bundle_ids.entry(TypeId::of::<T>()).or_insert_with(|| {
let mut component_ids= Vec::new(); let mut component_ids= Vec::new();
T::component_ids(components, &mut |id| component_ids.push(id)); T::component_ids(components, &mut |id| component_ids.push(id));
let id = BundleId(bundle_infos.len()); let id = BundleId(bundle_infos.len());
@ -1597,8 +1597,7 @@ impl Bundles {
unsafe { BundleInfo::new(core::any::type_name::<T>(), storages, components, component_ids, id) }; unsafe { BundleInfo::new(core::any::type_name::<T>(), storages, components, component_ids, id) };
bundle_infos.push(bundle_info); bundle_infos.push(bundle_info);
id id
}); })
id
} }
/// Registers a new [`BundleInfo`], which contains both explicit and required components for a statically known type. /// Registers a new [`BundleInfo`], which contains both explicit and required components for a statically known type.