From ba014547439ba07658724063edc662a210a86bf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Sat, 2 Jul 2022 09:19:41 +0200 Subject: [PATCH 1/3] enable fmt --- .github/workflows/ci.yml | 4 ++-- .rustfmt.toml | 2 +- benches/world.rs | 27 +++++++++---------------- examples/saveload.rs | 6 ++++-- specs-derive/src/impl_saveload.rs | 12 ++++------- src/join/mod.rs | 6 +----- src/lib.rs | 13 +++++++----- src/saveload/marker.rs | 2 +- src/saveload/mod.rs | 1 - src/saveload/tests.rs | 3 ++- src/storage/deref_flagged.rs | 19 +++++++++++++----- src/storage/flagged.rs | 5 ++++- src/storage/generic.rs | 29 ++++++++++++++++++--------- src/storage/mod.rs | 22 +++++++++++---------- src/storage/restrict.rs | 4 ++-- src/storage/storages.rs | 30 ++++++++++++++++++++++------ src/storage/tests.rs | 8 ++++++-- src/world/mod.rs | 6 ++++-- tests/saveload.rs | 33 +++++++++++++++++++++---------- 19 files changed, 141 insertions(+), 91 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 306994625..b827e5f77 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,8 +49,8 @@ jobs: if: matrix.toolchain == 'stable' && matrix.os == 'ubuntu-latest' # run rustfmt and clippy checks, but only once - #- run: cargo +nightly fmt --all -- --check - # if: matrix.toolchain == 'stable' && matrix.os == 'ubuntu-latest' + - run: cargo +nightly fmt --all -- --check + if: matrix.toolchain == 'stable' && matrix.os == 'ubuntu-latest' #- run: cargo +nightly clippy -Z unstable-options --workspace --all-targets --all-features # if: matrix.toolchain == 'stable' && matrix.os == 'ubuntu-latest' diff --git a/.rustfmt.toml b/.rustfmt.toml index b6d4d4369..b299429d8 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1,5 +1,5 @@ hard_tabs = false -merge_imports = true +imports_granularity = "Crate" reorder_impl_items = true use_field_init_shorthand = true use_try_shorthand = true diff --git a/benches/world.rs b/benches/world.rs index 662fad1d9..f9166baf1 100644 --- a/benches/world.rs +++ b/benches/world.rs @@ -54,30 +54,21 @@ fn world_build(b: &mut Bencher) { } fn create_now(b: &mut Bencher) { - b.iter_with_large_setup( - World::new, - |mut w| { - w.create_entity().build(); - }, - ); + b.iter_with_large_setup(World::new, |mut w| { + w.create_entity().build(); + }); } fn create_now_with_storage(b: &mut Bencher) { - b.iter_with_large_setup( - create_world, - |mut w| { - w.create_entity().with(CompInt(0)).build(); - }, - ); + b.iter_with_large_setup(create_world, |mut w| { + w.create_entity().with(CompInt(0)).build(); + }); } fn create_pure(b: &mut Bencher) { - b.iter_with_large_setup( - World::new, - |w| { - w.entities().create(); - }, - ); + b.iter_with_large_setup(World::new, |w| { + w.entities().create(); + }); } fn delete_now(b: &mut Bencher) { diff --git a/examples/saveload.rs b/examples/saveload.rs index 382672211..371fe63ef 100644 --- a/examples/saveload.rs +++ b/examples/saveload.rs @@ -3,8 +3,8 @@ extern crate ron; extern crate serde; extern crate specs; -use std::{convert::Infallible, fmt}; use ron::ser::PrettyConfig; +use std::{convert::Infallible, fmt}; use specs::{ prelude::*, @@ -157,7 +157,9 @@ fn main() { let mut buf = Vec::new(); let mut config = PrettyConfig::default(); config.struct_names = true; - let mut ser = ron::ser::Serializer::with_options(&mut buf, Some(config), Default::default()).unwrap(); + let mut ser = + ron::ser::Serializer::with_options(&mut buf, Some(config), Default::default()) + .unwrap(); // For serialization we use the // [`SerializeComponents`](struct.SerializeComponents.html)-trait's `serialize` diff --git a/specs-derive/src/impl_saveload.rs b/specs-derive/src/impl_saveload.rs index 52c366443..c407e0f9c 100644 --- a/specs-derive/src/impl_saveload.rs +++ b/specs-derive/src/impl_saveload.rs @@ -270,11 +270,9 @@ fn saveload_tuple_struct( let field_ids = saveload_fields .iter() .enumerate() - .map(|(i, _field_meta)| { - Index { - index: i as u32, - span: data.struct_token.span, - } + .map(|(i, _field_meta)| Index { + index: i as u32, + span: data.struct_token.span, }) .collect::>(); @@ -595,9 +593,7 @@ fn replace_entity_type(ty: &mut Type) { } } -fn single_parse_outer_from_args( - input: syn::parse::ParseStream, -) -> Result { +fn single_parse_outer_from_args(input: syn::parse::ParseStream) -> Result { Ok(Attribute { pound_token: syn::token::Pound { spans: [input.span()], diff --git a/src/join/mod.rs b/src/join/mod.rs index b9a4b8591..41eede95c 100644 --- a/src/join/mod.rs +++ b/src/join/mod.rs @@ -426,11 +426,7 @@ impl std::iter::Iterator for JoinIter { /// /// // add some entities to our world /// for _ in 0..10 { -/// let entity = world -/// .create_entity() -/// .with(Position) -/// .with(Collider) -/// .build(); +/// let entity = world.create_entity().with(Position).with(Collider).build(); /// } /// /// // check for collisions between entities diff --git a/src/lib.rs b/src/lib.rs index 972a840aa..e5a54dd50 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,8 @@ #![warn(missing_docs)] -#![cfg_attr(feature = "nightly", feature(generic_associated_types, associated_type_defaults))] +#![cfg_attr( + feature = "nightly", + feature(generic_associated_types, associated_type_defaults) +)] //! # SPECS Parallel ECS //! @@ -207,9 +210,9 @@ pub mod world; pub use hibitset::BitSet; pub use shred::{ - Accessor, AccessorCow, BatchAccessor, BatchController, BatchUncheckedWorld, - Dispatcher, DispatcherBuilder, Read, ReadExpect, RunNow, - RunningTime, StaticAccessor, System, SystemData, World, Write, WriteExpect, + Accessor, AccessorCow, BatchAccessor, BatchController, BatchUncheckedWorld, Dispatcher, + DispatcherBuilder, Read, ReadExpect, RunNow, RunningTime, StaticAccessor, System, SystemData, + World, Write, WriteExpect, }; pub use shrev::ReaderId; @@ -232,4 +235,4 @@ pub use crate::{ }; #[cfg(feature = "nightly")] -pub use crate::storage::DerefFlaggedStorage; \ No newline at end of file +pub use crate::storage::DerefFlaggedStorage; diff --git a/src/saveload/marker.rs b/src/saveload/marker.rs index cc6692e61..5aebdd85c 100644 --- a/src/saveload/marker.rs +++ b/src/saveload/marker.rs @@ -356,7 +356,7 @@ pub trait MarkerAllocator: Resource { new } else { - return None + return None; }; Some((storage.get(entity).unwrap(), new)) } diff --git a/src/saveload/mod.rs b/src/saveload/mod.rs index bf28da4ac..43e39a830 100644 --- a/src/saveload/mod.rs +++ b/src/saveload/mod.rs @@ -22,7 +22,6 @@ //! to identify entities even if local ids are different. The allocation //! of these ids is what `MarkerAllocator`s are responsible for. For an example, //! see the docs for the `Marker` trait. -//! use std::convert::Infallible; diff --git a/src/saveload/tests.rs b/src/saveload/tests.rs index 9ed2fe3da..2072e4e2c 100644 --- a/src/saveload/tests.rs +++ b/src/saveload/tests.rs @@ -65,7 +65,8 @@ mod marker_test { let mut buf = Vec::new(); let mut config = ron::ser::PrettyConfig::default(); config.struct_names = true; - let mut ser = ron::ser::Serializer::with_options(&mut buf, Some(config), Default::default()).unwrap(); + let mut ser = + ron::ser::Serializer::with_options(&mut buf, Some(config), Default::default()).unwrap(); world.exec( |(ents, comp_a, comp_b, markers, _alloc): ( diff --git a/src/storage/deref_flagged.rs b/src/storage/deref_flagged.rs index 5c9f8daf8..f4317fb71 100644 --- a/src/storage/deref_flagged.rs +++ b/src/storage/deref_flagged.rs @@ -13,7 +13,8 @@ use crate::{ use shrev::EventChannel; /// Wrapper storage that tracks modifications, insertions, and removals of -/// components through an `EventChannel`, in a similar manner to `FlaggedStorage`. +/// components through an `EventChannel`, in a similar manner to +/// `FlaggedStorage`. /// /// Unlike `FlaggedStorage`, this storage uses a wrapper type for mutable /// accesses that only emits modification events when the component is actually @@ -55,7 +56,10 @@ where } impl> UnprotectedStorage for DerefFlaggedStorage { - type AccessMut<'a> where T: 'a = FlaggedAccessMut<'a, >::AccessMut<'a>, C>; + type AccessMut<'a> + where + T: 'a, + = FlaggedAccessMut<'a, >::AccessMut<'a>, C>; unsafe fn clean(&mut self, has: B) where @@ -123,14 +127,19 @@ pub struct FlaggedAccessMut<'a, A, C> { } impl<'a, A, C> Deref for FlaggedAccessMut<'a, A, C> - where A: Deref +where + A: Deref, { type Target = C; - fn deref(&self) -> &Self::Target { self.access.deref() } + + fn deref(&self) -> &Self::Target { + self.access.deref() + } } impl<'a, A, C> DerefMut for FlaggedAccessMut<'a, A, C> - where A: DerefMut +where + A: DerefMut, { fn deref_mut(&mut self) -> &mut Self::Target { if self.emit { diff --git a/src/storage/flagged.rs b/src/storage/flagged.rs index 3d2fe53aa..4adb86828 100644 --- a/src/storage/flagged.rs +++ b/src/storage/flagged.rs @@ -201,7 +201,10 @@ where impl> UnprotectedStorage for FlaggedStorage { #[cfg(feature = "nightly")] - type AccessMut<'a> where T: 'a = >::AccessMut<'a>; + type AccessMut<'a> + where + T: 'a, + = >::AccessMut<'a>; unsafe fn clean(&mut self, has: B) where diff --git a/src/storage/generic.rs b/src/storage/generic.rs index 1f38ac0cc..68bfbefe6 100644 --- a/src/storage/generic.rs +++ b/src/storage/generic.rs @@ -1,11 +1,11 @@ #[cfg(feature = "nightly")] -use std::ops::DerefMut; +use crate::storage::UnprotectedStorage; use crate::{ - storage::{InsertResult, ReadStorage, WriteStorage, AccessMutReturn}, + storage::{AccessMutReturn, InsertResult, ReadStorage, WriteStorage}, world::{Component, Entity}, }; #[cfg(feature = "nightly")] -use crate::storage::UnprotectedStorage; +use std::ops::DerefMut; pub struct Seal; @@ -88,7 +88,9 @@ pub trait GenericWriteStorage { type Component: Component; /// The wrapper through with mutable access of a component is performed. #[cfg(feature = "nightly")] - type AccessMut<'a>: DerefMut where Self: 'a; + type AccessMut<'a>: DerefMut + where + Self: 'a; /// Get mutable access to an `Entity`s component fn get_mut(&mut self, entity: Entity) -> Option>; @@ -97,7 +99,10 @@ pub trait GenericWriteStorage { /// exist, it is automatically created using `Default::default()`. /// /// Returns None if the entity is dead. - fn get_mut_or_default(&mut self, entity: Entity) -> Option> + fn get_mut_or_default( + &mut self, + entity: Entity, + ) -> Option> where Self::Component: Default; @@ -115,9 +120,12 @@ impl<'a, T> GenericWriteStorage for WriteStorage<'a, T> where T: Component, { - type Component = T; #[cfg(feature = "nightly")] - type AccessMut<'b> where Self: 'b = <::Storage as UnprotectedStorage>::AccessMut<'b>; + type AccessMut<'b> + where + Self: 'b, + = <::Storage as UnprotectedStorage>::AccessMut<'b>; + type Component = T; fn get_mut(&mut self, entity: Entity) -> Option> { WriteStorage::get_mut(self, entity) @@ -153,9 +161,12 @@ impl<'a: 'b, 'b, T> GenericWriteStorage for &'b mut WriteStorage<'a, T> where T: Component, { - type Component = T; #[cfg(feature = "nightly")] - type AccessMut<'c> where Self: 'c = <::Storage as UnprotectedStorage>::AccessMut<'c>; + type AccessMut<'c> + where + Self: 'c, + = <::Storage as UnprotectedStorage>::AccessMut<'c>; + type Component = T; fn get_mut(&mut self, entity: Entity) -> Option> { WriteStorage::get_mut(*self, entity) diff --git a/src/storage/mod.rs b/src/storage/mod.rs index 8e52304fb..e08365ca2 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -1,21 +1,21 @@ //! Component storage types, implementations for component joins, etc. +#[cfg(feature = "nightly")] +pub use self::deref_flagged::{DerefFlaggedStorage, FlaggedAccessMut}; pub use self::{ data::{ReadStorage, WriteStorage}, entry::{Entries, OccupiedEntry, StorageEntry, VacantEntry}, flagged::FlaggedStorage, generic::{GenericReadStorage, GenericWriteStorage}, restrict::{ - ImmutableParallelRestriction, MutableParallelRestriction, RestrictedStorage, - SequentialRestriction, PairedStorage + ImmutableParallelRestriction, MutableParallelRestriction, PairedStorage, RestrictedStorage, + SequentialRestriction, }, storages::{ BTreeStorage, DefaultVecStorage, DenseVecStorage, HashMapStorage, NullStorage, VecStorage, }, track::{ComponentEvent, Tracked}, }; -#[cfg(feature = "nightly")] -pub use self::deref_flagged::{DerefFlaggedStorage, FlaggedAccessMut}; use self::storages::SliceAccess; @@ -39,11 +39,11 @@ use crate::{ use self::drain::Drain; mod data; +#[cfg(feature = "nightly")] +mod deref_flagged; mod drain; mod entry; mod flagged; -#[cfg(feature = "nightly")] -mod deref_flagged; mod generic; mod restrict; mod storages; @@ -328,7 +328,7 @@ where } /// Tries to mutate the data associated with an `Entity`. - pub fn get_mut(&mut self, e: Entity) -> Option > { + pub fn get_mut(&mut self, e: Entity) -> Option> { if self.data.mask.contains(e.id()) && self.entities.is_alive(e) { // SAFETY: We checked the mask, so all invariants are met. Some(unsafe { self.data.inner.get_mut(e.id()) }) @@ -507,7 +507,9 @@ where pub trait UnprotectedStorage: TryDefault { /// The wrapper through with mutable access of a component is performed. #[cfg(feature = "nightly")] - type AccessMut<'a>: DerefMut where Self: 'a; + type AccessMut<'a>: DerefMut + where + Self: 'a; /// Clean the storage given a bitset with bits set for valid indices. /// Allows us to safely drop the storage. @@ -581,8 +583,8 @@ pub trait UnprotectedStorage: TryDefault { unsafe fn remove(&mut self, id: Index) -> T; /// Drops the data associated with an `Index`. - /// This could be used when a more efficient implementation for it exists than `remove` when the data - /// is no longer needed. + /// This could be used when a more efficient implementation for it exists + /// than `remove` when the data is no longer needed. /// Defaults to simply calling `remove`. /// /// # Safety diff --git a/src/storage/restrict.rs b/src/storage/restrict.rs index 99e4ccca5..6ec1c5f79 100644 --- a/src/storage/restrict.rs +++ b/src/storage/restrict.rs @@ -12,7 +12,7 @@ use crate::join::Join; #[cfg(feature = "parallel")] use crate::join::ParJoin; use crate::{ - storage::{MaskedStorage, Storage, UnprotectedStorage, AccessMutReturn}, + storage::{AccessMutReturn, MaskedStorage, Storage, UnprotectedStorage}, world::{Component, EntitiesRes, Entity, Index}, }; @@ -248,7 +248,7 @@ where { /// Gets the component related to the current entry without checking whether /// the storage has it or not. - pub fn get_mut_unchecked(&mut self) -> AccessMutReturn<'_, C> { + pub fn get_mut_unchecked(&mut self) -> AccessMutReturn<'_, C> { unsafe { self.storage.borrow_mut().get_mut(self.index) } } } diff --git a/src/storage/storages.rs b/src/storage/storages.rs index 27417ec1e..7c8e0eab7 100644 --- a/src/storage/storages.rs +++ b/src/storage/storages.rs @@ -33,7 +33,10 @@ impl Default for BTreeStorage { impl UnprotectedStorage for BTreeStorage { #[cfg(feature = "nightly")] - type AccessMut<'a> where T: 'a = &'a mut T; + type AccessMut<'a> + where + T: 'a, + = &'a mut T; unsafe fn clean(&mut self, _has: B) where @@ -74,7 +77,10 @@ impl Default for HashMapStorage { impl UnprotectedStorage for HashMapStorage { #[cfg(feature = "nightly")] - type AccessMut<'a> where T: 'a = &'a mut T; + type AccessMut<'a> + where + T: 'a, + = &'a mut T; unsafe fn clean(&mut self, _has: B) where @@ -154,7 +160,10 @@ impl SliceAccess for DenseVecStorage { impl UnprotectedStorage for DenseVecStorage { #[cfg(feature = "nightly")] - type AccessMut<'a> where T: 'a = &'a mut T; + type AccessMut<'a> + where + T: 'a, + = &'a mut T; unsafe fn clean(&mut self, _has: B) where @@ -211,7 +220,10 @@ where T: Default, { #[cfg(feature = "nightly")] - type AccessMut<'a> where T: 'a = &'a mut T; + type AccessMut<'a> + where + T: 'a, + = &'a mut T; unsafe fn clean(&mut self, _has: B) where @@ -281,7 +293,10 @@ impl SliceAccess for VecStorage { impl UnprotectedStorage for VecStorage { #[cfg(feature = "nightly")] - type AccessMut<'a> where T: 'a = &'a mut T; + type AccessMut<'a> + where + T: 'a, + = &'a mut T; unsafe fn clean(&mut self, has: B) where @@ -346,7 +361,10 @@ where T: Default, { #[cfg(feature = "nightly")] - type AccessMut<'a> where T: 'a = &'a mut T; + type AccessMut<'a> + where + T: 'a, + = &'a mut T; unsafe fn clean(&mut self, _has: B) where diff --git a/src/storage/tests.rs b/src/storage/tests.rs index b3af9a0f4..6c5b76574 100644 --- a/src/storage/tests.rs +++ b/src/storage/tests.rs @@ -361,7 +361,9 @@ mod test { if let Err(err) = s.insert(Entity::new(i, Generation::new(1)), (i + 2718).into()) { panic!("Failed to insert component into entity! {:?}", err); } - if s.insert(Entity::new(i, Generation::new(2)), (i + 31415).into()).is_ok() { + if s.insert(Entity::new(i, Generation::new(2)), (i + 31415).into()) + .is_ok() + { panic!("Overwrote entity generation! I shouldn't have been allowed to do this!"); } } @@ -383,7 +385,9 @@ mod test { let mut s: Storage = create(&mut w); for i in 0..1_000 { - if s.insert(Entity::new(i, Generation::new(2)), (i + 2718).into()).is_ok() { + if s.insert(Entity::new(i, Generation::new(2)), (i + 2718).into()) + .is_ok() + { panic!("Overwrote entity generation! I shouldn't have been allowed to do this!"); } } diff --git a/src/world/mod.rs b/src/world/mod.rs index aa74b50a0..e6bc356b5 100644 --- a/src/world/mod.rs +++ b/src/world/mod.rs @@ -65,7 +65,8 @@ pub trait Builder { #[cfg(not(feature = "parallel"))] fn with(self, c: C) -> Self; - /// Convenience method that calls `self.with(component)` if `Some(component)` is provided + /// Convenience method that calls `self.with(component)` if + /// `Some(component)` is provided /// /// # Panics /// @@ -82,7 +83,8 @@ pub trait Builder { } } - /// Convenience method that calls `self.with(component)` if `Some(component)` is provided + /// Convenience method that calls `self.with(component)` if + /// `Some(component)` is provided /// /// # Panics /// diff --git a/tests/saveload.rs b/tests/saveload.rs index 30a52e45d..26e717486 100644 --- a/tests/saveload.rs +++ b/tests/saveload.rs @@ -57,21 +57,19 @@ mod tests { #[derive(Clone)] struct UnserializableType { - inner: u32 + inner: u32, } impl Default for UnserializableType { fn default() -> Self { - Self { - inner: 0 - } + Self { inner: 0 } } } #[derive(Serialize, Deserialize, Clone)] struct ComplexSerdeType { #[serde(skip, default)] - opaque: UnserializableType + opaque: UnserializableType, } #[derive(ConvertSaveload)] @@ -79,7 +77,7 @@ mod tests { #[convert_save_load_skip_convert] #[convert_save_load_attr(serde(skip, default))] opaque: UnserializableType, - other: u32 + other: u32, } #[derive(ConvertSaveload)] @@ -95,13 +93,13 @@ mod tests { #[derive(ConvertSaveload)] enum NamedEnumContainsSerdeType { A(Entity), - B { inner_baz: NamedContainsSerdeType } + B { inner_baz: NamedContainsSerdeType }, } #[derive(ConvertSaveload)] enum UnnamedEnumContainsSerdeType { A(Entity), - B(NamedContainsSerdeType) + B(NamedContainsSerdeType), } #[derive(ConvertSaveload)] @@ -131,8 +129,23 @@ mod tests { black_box::(OneFieldTuple(entity)); black_box::(TwoFieldTuple(entity, 5)); black_box::(TupleSerdeType(5)); - black_box::(NamedContainsSerdeType{ e: entity, a: ComplexSerdeType { opaque: UnserializableType::default() }, b: ComplexSerdeMixedType { opaque: UnserializableType::default(), other: 5 } }); - black_box::(TupleContainsSerdeType(entity, ComplexSerdeMixedType { opaque: UnserializableType::default(), other: 5 } )); + black_box::(NamedContainsSerdeType { + e: entity, + a: ComplexSerdeType { + opaque: UnserializableType::default(), + }, + b: ComplexSerdeMixedType { + opaque: UnserializableType::default(), + other: 5, + }, + }); + black_box::(TupleContainsSerdeType( + entity, + ComplexSerdeMixedType { + opaque: UnserializableType::default(), + other: 5, + }, + )); black_box::(NamedEnumContainsSerdeType::A(entity)); black_box::(UnnamedEnumContainsSerdeType::A(entity)); // The derive will work for all variants From 3b04f954efc5353b19949dfe07e5b45816363f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Sat, 2 Jul 2022 09:25:10 +0200 Subject: [PATCH 2/3] apply some clippy fixes --- src/world/lazy.rs | 11 ++--------- src/world/mod.rs | 2 +- src/world/world_ext.rs | 4 ++-- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/world/lazy.rs b/src/world/lazy.rs index 8c61dd116..d789b6095 100644 --- a/src/world/lazy.rs +++ b/src/world/lazy.rs @@ -7,7 +7,7 @@ struct Queue(SegQueue); impl Default for Queue { fn default() -> Self { - Self(SegQueue::new()) + Self(SegQueue::default()) } } @@ -152,18 +152,11 @@ where /// Please note that the provided methods take `&self` /// so there's no need to get `LazyUpdate` mutably. /// This resource is added to the world by default. +#[derive(Default)] pub struct LazyUpdate { queue: Arc>>, } -impl Default for LazyUpdate { - fn default() -> Self { - Self { - queue: Default::default(), - } - } -} - impl LazyUpdate { parallel_feature! { /// Lazily inserts a component for an entity. diff --git a/src/world/mod.rs b/src/world/mod.rs index e6bc356b5..f79dccd83 100644 --- a/src/world/mod.rs +++ b/src/world/mod.rs @@ -191,7 +191,7 @@ impl<'a> Builder for EntityBuilder<'a> { #[inline] fn with(self, c: T) -> Self { { - let mut storage: WriteStorage = SystemData::fetch(&self.world); + let mut storage: WriteStorage = SystemData::fetch(self.world); // This can't fail. This is guaranteed by the lifetime 'a // in the EntityBuilder. storage.insert(self.entity, c).unwrap(); diff --git a/src/world/world_ext.rs b/src/world/world_ext.rs index ffa2fd6c8..aab5b6f75 100644 --- a/src/world/world_ext.rs +++ b/src/world/world_ext.rs @@ -342,7 +342,7 @@ impl WorldExt for World { } fn entities(&self) -> Read { - Read::fetch(&self) + Read::fetch(self) } fn entities_mut(&self) -> FetchMut { @@ -410,7 +410,7 @@ impl WorldExt for World { .or_insert_with(Default::default); for storage in self .fetch_mut::>() - .iter_mut(&self) + .iter_mut(self) { storage.drop(delete); } From d0fea2c762a9a9171f1f22b5704e975ef09542c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Sat, 2 Jul 2022 09:27:57 +0200 Subject: [PATCH 3/3] add missing fmt --- src/world/world_ext.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/world/world_ext.rs b/src/world/world_ext.rs index aab5b6f75..49f667734 100644 --- a/src/world/world_ext.rs +++ b/src/world/world_ext.rs @@ -408,10 +408,7 @@ impl WorldExt for World { fn delete_components(&mut self, delete: &[Entity]) { self.entry::>() .or_insert_with(Default::default); - for storage in self - .fetch_mut::>() - .iter_mut(self) - { + for storage in self.fetch_mut::>().iter_mut(self) { storage.drop(delete); } }