From e028d89e15fd219854cbd7122d63ebd2fa37d390 Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 10 Apr 2024 22:45:35 +0200 Subject: feat(ecs): add weak ref single --- ecs/src/lib.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'ecs/src/lib.rs') diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs index db82d91..8a5de64 100644 --- a/ecs/src/lib.rs +++ b/ecs/src/lib.rs @@ -353,12 +353,12 @@ pub struct SoleAlreadyExistsError(pub &'static str); #[derive(Debug, Default)] struct SoleStorage { - storage: HashMap>>, + storage: HashMap>>>, } impl SoleStorage { - fn get(&self) -> Option<&Lock>> + fn get(&self) -> Option<&Arc>>> { self.storage.get(&TypeId::of::()) } @@ -371,7 +371,10 @@ impl SoleStorage return Err(SoleAlreadyExistsError(type_name::())); } - self.storage.insert(sole_type_id, Lock::new(Box::new(sole))); + // TODO: Reconsider this maybe? + #[allow(clippy::arc_with_non_send_sync)] + self.storage + .insert(sole_type_id, Arc::new(Lock::new(Box::new(sole)))); Ok(()) } -- cgit v1.2.3-18-g5258