From 05599f32ce605d255a119374ad844c46e5e9b96b Mon Sep 17 00:00:00 2001 From: leudz Date: Wed, 20 Jan 2021 16:02:18 +0100 Subject: [PATCH 1/3] update to latest shipyard --- src/app_builder.rs | 10 ++++---- src/test/tree.rs | 14 +++++------ src/tracked_unique.rs | 55 +++++++++++++++++++++++++++++++++---------- 3 files changed, 55 insertions(+), 24 deletions(-) diff --git a/src/app_builder.rs b/src/app_builder.rs index 5b646e0..c14bfb7 100644 --- a/src/app_builder.rs +++ b/src/app_builder.rs @@ -325,7 +325,8 @@ impl<'a> AppBuilder<'a> { .is_first() { self.app.world.borrow::>().unwrap().update_pack(); - self.resets.push(system!(reset_update_pack::)); + self.resets + .push(reset_update_pack::.into_workload_system().unwrap()); } self @@ -340,7 +341,8 @@ impl<'a> AppBuilder<'a> { .associate_plugin::(&self.track_current_plugin, reason) .is_first() { - self.resets.push(system!(reset_tracked_unique::)); + self.resets + .push(reset_tracked_unique::.into_workload_system().unwrap()); } self @@ -443,8 +445,8 @@ impl<'a> AppBuilder<'a> { } #[track_caller] - pub fn add_system(&mut self, system: WorkloadSystem) -> &mut Self { - self.systems.push(system); + pub fn add_system>(&mut self, system: S) -> &mut Self { + self.systems.push(system.into_workload_system().unwrap()); self } diff --git a/src/test/tree.rs b/src/test/tree.rs index 69bb8ea..a62cb42 100644 --- a/src/test/tree.rs +++ b/src/test/tree.rs @@ -34,7 +34,7 @@ impl Plugin for TreePlugin { fn build(&self, app: &mut AppBuilder) { // needs direct update pack since TreePlugin clears updates on its own. app.update_pack::("update in response to ChildOf changes") - .add_system(system!(indexing::tree_indexing)); + .add_system(&indexing::tree_indexing); } } @@ -57,11 +57,11 @@ mod tests { let mut indexing = WorkloadBuilder::new("indexing"); indexing - .with_system(system!(indexing::tree_indexing)) - .with_system(system!(|mut vm_child_of: ViewMut| { + .with_system(&indexing::tree_indexing) + .with_system(&|mut vm_child_of: ViewMut| { vm_child_of.clear_all_inserted_and_modified(); vm_child_of.take_deleted(); - })) + }) .add_to_world(&world) .unwrap(); @@ -497,10 +497,10 @@ mod tests { }); WorkloadBuilder::new("default") - .with_system(system!(indexing::tree_indexing)) - .with_system(system!(|mut vm_child_of: ViewMut| { + .with_system(&indexing::tree_indexing) + .with_system(&|mut vm_child_of: ViewMut| { vm_child_of.clear_all_inserted_and_modified(); - })) + }) .add_to_world(&app.world) .unwrap(); diff --git a/src/tracked_unique.rs b/src/tracked_unique.rs index 1696906..7163a25 100644 --- a/src/tracked_unique.rs +++ b/src/tracked_unique.rs @@ -8,18 +8,31 @@ use std::{fmt, ops::Deref, ops::DerefMut}; pub struct TrackedValue(InnerTrackedState, T); -pub struct TrackedMut<'a, T: 'static>(UniqueViewMut<'a, TrackedValue>); pub struct Tracked<'a, T: 'static>(UniqueView<'a, TrackedValue>); -impl<'a, T: 'static + Send + Sync> Borrow<'a> for Tracked<'a, T> { - fn borrow( - all_storages: &'a AllStorages, - all_borrow: Option>, - ) -> Result +pub struct TrackedBorrower(T); + +impl IntoBorrow for Tracked<'_, T> { + type Borrow = TrackedBorrower; +} + +impl<'a, T: 'static + Send + Sync> Borrow<'a> for TrackedBorrower { + type View = Tracked<'a, T>; + + fn borrow(world: &'a World) -> Result + where + Self: Sized, + { + Ok(Tracked(world.borrow()?)) + } +} + +impl<'a, T: 'static + Send + Sync> AllStoragesBorrow<'a> for TrackedBorrower { + fn all_borrow(all_storages: &'a AllStorages) -> Result where Self: Sized, { - Ok(Tracked(Borrow::borrow(all_storages, all_borrow)?)) + Ok(Tracked(all_storages.borrow()?)) } } @@ -29,15 +42,31 @@ unsafe impl<'a, T: 'static + Send + Sync> BorrowInfo for Tracked<'a, T> { } } -impl<'a, T: 'static + Send + Sync> Borrow<'a> for TrackedMut<'a, T> { - fn borrow( - all_storages: &'a AllStorages, - all_borrow: Option>, - ) -> Result +pub struct TrackedMut<'a, T: 'static>(UniqueViewMut<'a, TrackedValue>); + +pub struct TrackedMutBorrower(T); + +impl<'a, T: 'static + Send + Sync> IntoBorrow for TrackedMut<'a, T> { + type Borrow = TrackedMutBorrower; +} + +impl<'a, T: 'static + Send + Sync> Borrow<'a> for TrackedMutBorrower { + type View = TrackedMut<'a, T>; + + fn borrow(world: &'a World) -> Result + where + Self: Sized, + { + Ok(TrackedMut(world.borrow()?)) + } +} + +impl<'a, T: 'static + Send + Sync> AllStoragesBorrow<'a> for TrackedMutBorrower { + fn all_borrow(all_storages: &'a AllStorages) -> Result where Self: Sized, { - Ok(TrackedMut(Borrow::borrow(all_storages, all_borrow)?)) + Ok(TrackedMut(all_storages.borrow()?)) } } From 05a8e1c83846f82413c0b372ae36a5fc73b1ebb9 Mon Sep 17 00:00:00 2001 From: leudz Date: Wed, 20 Jan 2021 16:25:47 +0100 Subject: [PATCH 2/3] simplify tests --- src/test/tree.rs | 167 ++++++++++++----------------------------------- 1 file changed, 43 insertions(+), 124 deletions(-) diff --git a/src/test/tree.rs b/src/test/tree.rs index a62cb42..f036c25 100644 --- a/src/test/tree.rs +++ b/src/test/tree.rs @@ -47,11 +47,7 @@ mod tests { // Create a new world let world = World::new(); // Track modifications to the child_of components - world - .run(|mut vm_child_of: ViewMut| { - vm_child_of.update_pack(); - }) - .unwrap(); + world.borrow::>().unwrap().update_pack(); // Add the indexing workload let mut indexing = WorkloadBuilder::new("indexing"); @@ -70,11 +66,9 @@ mod tests { #[test] fn insert_single_entity_with_no_children() { - let world = setup_world_with_index_system(); + let mut world = setup_world_with_index_system(); // Add a parent and child entity - let a = world - .run(|mut entities: EntitiesViewMut| entities.add_entity((), ())) - .unwrap(); + let a = world.add_entity(()); // Run the indexing workload world.run_default().unwrap(); @@ -92,17 +86,10 @@ mod tests { #[test] fn insert_single_child() { - let world = setup_world_with_index_system(); + let mut world = setup_world_with_index_system(); // Add a parent and child entity - let (a, a1) = world - .run( - |mut entities: EntitiesViewMut, mut vm_child_of: ViewMut| { - let a = entities.add_entity((), ()); - let a1 = entities.add_entity(&mut vm_child_of, ChildOf(a, Ordered::hinted(1))); - (a, a1) - }, - ) - .unwrap(); + let a = world.add_entity(()); + let a1 = world.add_entity((ChildOf(a, Ordered::hinted(1)),)); // Run the indexing workload world.run_default().unwrap(); @@ -138,20 +125,12 @@ mod tests { #[test] fn insert_many_siblings() { - let world = setup_world_with_index_system(); + let mut world = setup_world_with_index_system(); // Add a parent entity with many children - let (a, a1, a2, a3) = world - .run( - |mut entities: EntitiesViewMut, mut vm_child_of: ViewMut| { - let a = entities.add_entity((), ()); - let a1 = entities.add_entity(&mut vm_child_of, ChildOf(a, Ordered::hinted(1))); - let a2 = entities.add_entity(&mut vm_child_of, ChildOf(a, Ordered::hinted(2))); - let a3 = entities.add_entity(&mut vm_child_of, ChildOf(a, Ordered::hinted(3))); - - (a, a1, a2, a3) - }, - ) - .unwrap(); + let a = world.add_entity(()); + let a1 = world.add_entity((ChildOf(a, Ordered::hinted(1)),)); + let a2 = world.add_entity((ChildOf(a, Ordered::hinted(2)),)); + let a3 = world.add_entity((ChildOf(a, Ordered::hinted(3)),)); // Run the indexing workload world.run_default().unwrap(); @@ -201,19 +180,12 @@ mod tests { #[test] fn insert_deep_children() { - let world = setup_world_with_index_system(); - let (a, a1, a2, a3) = world - .run( - |mut entities: EntitiesViewMut, mut vm_child_of: ViewMut| { - let a = entities.add_entity((), ()); - let a1 = entities.add_entity(&mut vm_child_of, ChildOf(a, Ordered::hinted(1))); - let a2 = entities.add_entity(&mut vm_child_of, ChildOf(a1, Ordered::hinted(2))); - let a3 = entities.add_entity(&mut vm_child_of, ChildOf(a2, Ordered::hinted(3))); + let mut world = setup_world_with_index_system(); - (a, a1, a2, a3) - }, - ) - .unwrap(); + let a = world.add_entity(()); + let a1 = world.add_entity((ChildOf(a, Ordered::hinted(1)),)); + let a2 = world.add_entity((ChildOf(a1, Ordered::hinted(2)),)); + let a3 = world.add_entity((ChildOf(a2, Ordered::hinted(3)),)); // Run the indexing workload world.run_default().unwrap(); @@ -255,17 +227,10 @@ mod tests { #[test] // TODO: Complete this test fn update_entity_as_child_of_self() { - let world = setup_world_with_index_system(); - world - .run( - |mut entities: EntitiesViewMut, mut vm_child_of: ViewMut| { - let a = entities.add_entity((), ()); - entities.add_component(a, &mut vm_child_of, ChildOf(a, Ordered::hinted(1))); + let mut world = setup_world_with_index_system(); - a - }, - ) - .unwrap(); + let a = world.add_entity(()); + world.add_component(a, (ChildOf(a, Ordered::hinted(1)),)); // Run the indexing workload world.run_default().unwrap(); @@ -273,29 +238,16 @@ mod tests { #[test] fn delete_only_child() { - let world = setup_world_with_index_system(); + let mut world = setup_world_with_index_system(); // Add a parent and child entity - let (a, a1) = world - .run( - |mut entities: EntitiesViewMut, mut vm_child_of: ViewMut| { - let a = entities.add_entity((), ()); - let a1 = entities.add_entity(&mut vm_child_of, ChildOf(a, Ordered::hinted(1))); - - (a, a1) - }, - ) - .unwrap(); + let a = world.add_entity(()); + let a1 = world.add_entity((ChildOf(a, Ordered::hinted(1)),)); // Run the indexing workload world.run_default().unwrap(); // Delete the child entity - world - .run(|mut vm_child_of: ViewMut| { - // remove should not be used as it is untracked for whatever reason... - vm_child_of.delete(a1); - }) - .unwrap(); + world.delete_component::<(ChildOf,)>(a1); // Run the indexing workload world.run_default().unwrap(); @@ -317,30 +269,19 @@ mod tests { #[test] fn delete_first_and_last_siblings() { - let world = setup_world_with_index_system(); - let (a, a1, a2, a3) = world - .run( - |mut entities: EntitiesViewMut, mut vm_child_of: ViewMut| { - let a = entities.add_entity((), ()); - let a1 = entities.add_entity(&mut vm_child_of, ChildOf(a, Ordered::hinted(1))); - let a2 = entities.add_entity(&mut vm_child_of, ChildOf(a, Ordered::hinted(2))); - let a3 = entities.add_entity(&mut vm_child_of, ChildOf(a, Ordered::hinted(3))); + let mut world = setup_world_with_index_system(); - (a, a1, a2, a3) - }, - ) - .unwrap(); + let a = world.add_entity(()); + let a1 = world.add_entity((ChildOf(a, Ordered::hinted(1)),)); + let a2 = world.add_entity((ChildOf(a, Ordered::hinted(2)),)); + let a3 = world.add_entity((ChildOf(a, Ordered::hinted(3)),)); // Run the indexing workload world.run_default().unwrap(); // Delete the first and last siblings - world - .run(|mut vm_child_of: ViewMut| { - vm_child_of.delete(a1); - vm_child_of.delete(a3); - }) - .unwrap(); + world.delete_component::<(ChildOf,)>(a1); + world.delete_component::<(ChildOf,)>(a3); // Run the indexing workload world.run_default().unwrap(); @@ -367,29 +308,18 @@ mod tests { #[test] fn delete_middle_sibling() { - let world = setup_world_with_index_system(); - let (a, a1, a2, a3) = world - .run( - |mut entities: EntitiesViewMut, mut vm_child_of: ViewMut| { - let a = entities.add_entity((), ()); - let a1 = entities.add_entity(&mut vm_child_of, ChildOf(a, Ordered::hinted(1))); - let a2 = entities.add_entity(&mut vm_child_of, ChildOf(a, Ordered::hinted(2))); - let a3 = entities.add_entity(&mut vm_child_of, ChildOf(a, Ordered::hinted(3))); + let mut world = setup_world_with_index_system(); - (a, a1, a2, a3) - }, - ) - .unwrap(); + let a = world.add_entity(()); + let a1 = world.add_entity((ChildOf(a, Ordered::hinted(1)),)); + let a2 = world.add_entity((ChildOf(a, Ordered::hinted(2)),)); + let a3 = world.add_entity((ChildOf(a, Ordered::hinted(3)),)); // Run the indexing workload world.run_default().unwrap(); // Delete the first and last siblings - world - .run(|mut vm_child_of: ViewMut| { - vm_child_of.delete(a2); - }) - .unwrap(); + world.delete_component::<(ChildOf,)>(a2); // Run the indexing workload world.run_default().unwrap(); @@ -417,28 +347,17 @@ mod tests { #[test] fn delete_middle_ancestor() { - let world = setup_world_with_index_system(); - let (a, a1, a2) = world - .run( - |mut entities: EntitiesViewMut, mut vm_child_of: ViewMut| { - let a = entities.add_entity((), ()); - let a1 = entities.add_entity(&mut vm_child_of, ChildOf(a, Ordered::hinted(1))); - let a2 = entities.add_entity(&mut vm_child_of, ChildOf(a1, Ordered::hinted(2))); + let mut world = setup_world_with_index_system(); - (a, a1, a2) - }, - ) - .unwrap(); + let a = world.add_entity(()); + let a1 = world.add_entity((ChildOf(a, Ordered::hinted(1)),)); + let a2 = world.add_entity((ChildOf(a1, Ordered::hinted(2)),)); // Run the indexing workload world.run_default().unwrap(); // Delete the first and last siblings - world - .run(|mut vm_child_of: ViewMut| { - vm_child_of.delete(a1); - }) - .unwrap(); + world.delete_component::<(ChildOf,)>(a1); // Run the indexing workload world.run_default().unwrap(); @@ -620,13 +539,13 @@ mod tests { // test inserting & overwriting after deleting // a2 updated to ord 7, a1 child of a8 - let (a8,) = app.run( + let a8 = app.run( |mut entities: EntitiesViewMut, mut vm_child_of: ViewMut| { (&mut vm_child_of).get(a2).unwrap().1 = Ordered::hinted(7); let a8 = entities.add_entity(&mut vm_child_of, ChildOf(a, Ordered::hinted(8))); (&mut vm_child_of).get(a1).unwrap().0 = a8; - (a8,) + a8 }, ); From 61aa624fb158ca89d987cb0c1058935417ef142f Mon Sep 17 00:00:00 2001 From: leudz Date: Wed, 20 Jan 2021 17:41:32 +0100 Subject: [PATCH 3/3] clean up removes unnecessary bounds makes TypeIdBuckets::entries allocation free --- src/app.rs | 5 ++--- src/app_add_cycle.rs | 16 +++++++--------- src/app_builder.rs | 37 ++++++++++++++----------------------- src/tracked_unique.rs | 32 ++++++++++++++++---------------- src/type_names.rs | 2 +- 5 files changed, 40 insertions(+), 52 deletions(-) diff --git a/src/app.rs b/src/app.rs index bc6778d..058c587 100644 --- a/src/app.rs +++ b/src/app.rs @@ -7,7 +7,6 @@ use crate::{ use shipyard::*; use tracing::trace_span; -#[allow(clippy::needless_doctest_main)] /// Containers of app logic and data pub struct App { pub world: World, @@ -32,7 +31,7 @@ impl App { #[track_caller] pub fn add_plugin_workload

(&mut self, plugin: P) -> AppWorkload where - P: Plugin + 'static, + P: Plugin, { self.add_plugin_workload_with_info(plugin).0 } @@ -40,7 +39,7 @@ impl App { #[track_caller] pub fn add_plugin_workload_with_info

(&mut self, plugin: P) -> (AppWorkload, AppWorkloadInfo) where - P: Plugin + 'static, + P: Plugin, { let workload_name = type_name::

(); let workload_type_id = TypeId::of::

(); diff --git a/src/app_add_cycle.rs b/src/app_add_cycle.rs index 65fd19a..bf0b0eb 100644 --- a/src/app_add_cycle.rs +++ b/src/app_add_cycle.rs @@ -85,7 +85,7 @@ impl App { cumulative_update_packed.associate( up_type, CycleWorkloadAssociations { - plugins: assoc, + plugins: assoc.to_vec(), workload_plugin_id: plugin_id, workload: name.clone(), }, @@ -99,7 +99,7 @@ impl App { cumulative_tracked_uniques.associate( tracked_type, CycleWorkloadAssociations { - plugins: assoc, + plugins: assoc.to_vec(), workload: name.clone(), workload_plugin_id: plugin_id, }, @@ -108,7 +108,7 @@ impl App { } } - names_checked.push(name.clone()); + names_checked.push(name); } let mut errs = Vec::::new(); @@ -117,12 +117,11 @@ impl App { errs.extend( cumulative_update_packed .entries() - .into_iter() - .filter(|((_, _), workloads_dependent)| workloads_dependent.len() > 1) + .filter(|(_, workloads_dependent)| workloads_dependent.len() > 1) .map(|((_, update_pack_storage_name), workloads_dependent)| { CycleCheckError::UpdatePackResetInMultipleWorkloads { update_pack: update_pack_storage_name, - conflicts: workloads_dependent, + conflicts: workloads_dependent.to_vec(), } }), ); @@ -131,12 +130,11 @@ impl App { errs.extend( cumulative_tracked_uniques .entries() - .into_iter() - .filter(|((_, _), workloads_dependent)| workloads_dependent.len() > 1) + .filter(|(_, workloads_dependent)| workloads_dependent.len() > 1) .map(|((_, tracked_unique_storage_name), workloads_dependent)| { CycleCheckError::TrackedUniqueResetInMultipleWorkloads { tracked_unique: tracked_unique_storage_name, - conflicts: workloads_dependent, + conflicts: workloads_dependent.to_vec(), } }), ); diff --git a/src/app_builder.rs b/src/app_builder.rs index c14bfb7..bbb98f7 100644 --- a/src/app_builder.rs +++ b/src/app_builder.rs @@ -35,13 +35,12 @@ pub(crate) struct TypeIdBuckets { pub(crate) type_plugins_lookup: HashMap>, } -impl std::fmt::Debug for TypeIdBuckets { +impl std::fmt::Debug for TypeIdBuckets { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_map() .entry(&"association", &self.name) .entries( self.entries() - .into_iter() .map(|((_, name), associated)| (name, associated)), ) .finish() @@ -68,18 +67,17 @@ impl TypeIdBuckets { } } -impl TypeIdBuckets { - pub(crate) fn entries(&self) -> Vec<((TypeId, &'static str), Vec)> { - self.type_plugins_lookup - .iter() - .map(|(id, associations)| -> ((TypeId, &'static str), Vec) { +impl TypeIdBuckets { + pub(crate) fn entries(&self) -> impl Iterator + '_ { + self.type_plugins_lookup.iter().map( + move |(id, associations)| -> ((TypeId, &'static str), &[T]) { let name = self .track_type_names .lookup_name(&id) .expect("all type ids with associations have a name saved"); - ((*id, name), associations.to_vec()) - }) - .collect() + ((*id, name), associations) + }, + ) } pub(crate) fn associate_type(&mut self, assoc: T) -> AssociateResult { @@ -219,9 +217,9 @@ pub struct AppWorkloadInfo { } #[derive(Clone)] -pub(crate) struct Blind(pub T); +pub(crate) struct Blind(pub T); -impl std::fmt::Debug for Blind { +impl std::fmt::Debug for Blind { fn fmt(&self, mut f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(&mut f, "Blind<{}>", type_name::()) } @@ -234,7 +232,7 @@ impl AppWorkload { for workload_name in self.names.iter() { let span = trace_span!("AppWorkload::run", ?workload_name); let _span = span.enter(); - app.world.run_workload(&workload_name).unwrap(); + app.world.run_workload(workload_name).unwrap(); } } } @@ -282,17 +280,10 @@ impl<'a> AppBuilder<'a> { signature, } = self; - let mut update_workload = systems.into_iter().fold( - WorkloadBuilder::new(update_stage.clone()), - |mut acc: WorkloadBuilder, system: WorkloadSystem| { - acc.with_system(system); - acc - }, - ); + let mut update_workload = WorkloadBuilder::new(update_stage.clone()); - for reset_system in resets { - update_workload.with_system(reset_system); - } + update_workload.extend(systems); + update_workload.extend(resets); let info = update_workload.add_to_world_with_info(&app.world).unwrap(); ( diff --git a/src/tracked_unique.rs b/src/tracked_unique.rs index 7163a25..8bb75b8 100644 --- a/src/tracked_unique.rs +++ b/src/tracked_unique.rs @@ -6,9 +6,9 @@ use crate::prelude::*; use core::any::type_name; use std::{fmt, ops::Deref, ops::DerefMut}; -pub struct TrackedValue(InnerTrackedState, T); +pub struct TrackedValue(InnerTrackedState, T); -pub struct Tracked<'a, T: 'static>(UniqueView<'a, TrackedValue>); +pub struct Tracked<'a, T>(UniqueView<'a, TrackedValue>); pub struct TrackedBorrower(T); @@ -42,9 +42,9 @@ unsafe impl<'a, T: 'static + Send + Sync> BorrowInfo for Tracked<'a, T> { } } -pub struct TrackedMut<'a, T: 'static>(UniqueViewMut<'a, TrackedValue>); +pub struct TrackedMut<'a, T>(UniqueViewMut<'a, TrackedValue>); -pub struct TrackedMutBorrower(T); +pub struct TrackedMutBorrower(T); impl<'a, T: 'static + Send + Sync> IntoBorrow for TrackedMut<'a, T> { type Borrow = TrackedMutBorrower; @@ -102,7 +102,7 @@ impl Tracked<'_, T> { } } -impl Deref for Tracked<'_, T> { +impl Deref for Tracked<'_, T> { type Target = T; #[inline(always)] @@ -111,7 +111,7 @@ impl Deref for Tracked<'_, T> { } } -impl Deref for TrackedMut<'_, T> { +impl Deref for TrackedMut<'_, T> { type Target = T; #[inline(always)] @@ -120,7 +120,7 @@ impl Deref for TrackedMut<'_, T> { } } -impl DerefMut for TrackedMut<'_, T> { +impl DerefMut for TrackedMut<'_, T> { #[inline(always)] fn deref_mut(&mut self) -> &mut T { self.0 .0 = InnerTrackedState::Modified; @@ -128,31 +128,31 @@ impl DerefMut for TrackedMut<'_, T> { } } -impl AsRef for Tracked<'_, T> { +impl AsRef for Tracked<'_, T> { fn as_ref(&self) -> &T { - &**self + &*self } } -impl AsRef for TrackedMut<'_, T> { +impl AsRef for TrackedMut<'_, T> { fn as_ref(&self) -> &T { - &**self + &*self } } -impl AsMut for TrackedMut<'_, T> { +impl AsMut for TrackedMut<'_, T> { fn as_mut(&mut self) -> &mut T { - &mut **self + &mut *self } } -impl fmt::Display for Tracked<'_, T> { +impl fmt::Display for Tracked<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&**self, f) } } -impl fmt::Debug for Tracked<'_, T> { +impl fmt::Debug for Tracked<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) } @@ -160,7 +160,7 @@ impl fmt::Debug for Tracked<'_, T> { /// Add [TrackedUnique] of `T` and reset tracking at the end of every update. #[derive(Default)] -pub struct TrackedUniquePlugin(T); +pub struct TrackedUniquePlugin(T); impl TrackedUniquePlugin { pub fn new(initial_value: T) -> Self { diff --git a/src/type_names.rs b/src/type_names.rs index 2120f26..b4d8fc3 100644 --- a/src/type_names.rs +++ b/src/type_names.rs @@ -19,6 +19,6 @@ impl TypeNames { } pub fn lookup_name(&self, type_id: &TypeId) -> Option<&'static str> { - self.0.borrow().get(type_id).map(|a| *a as &'static str) + self.0.borrow().get(type_id).copied() } }