From b827d47b2c01b2940de43d40cb877e90784ba211 Mon Sep 17 00:00:00 2001 From: hodasemi Date: Sun, 6 Apr 2025 11:58:58 +0200 Subject: [PATCH] Provide life time decoupled version --- ecs/src/world.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ecs/src/world.rs b/ecs/src/world.rs index 3936cb2..785d7af 100644 --- a/ecs/src/world.rs +++ b/ecs/src/world.rs @@ -181,6 +181,20 @@ impl World { .unwrap()) } + pub fn entities_mut_unchecked<'a, const N: usize>( + &mut self, + entities: [Entity; N], + ) -> std::result::Result<[&'a mut EntityObject; N], EntityNotFoundError> { + Ok(unsafe { remove_life_time_mut(&mut self.entities) } + .get_disjoint_mut::(entities.iter().collect::>().try_into().unwrap()) + .into_iter() + .enumerate() + .map(|(i, entity_opt)| entity_opt.ok_or(EntityNotFoundError::new(entities[i]))) + .collect::, _>>()? + .try_into() + .unwrap()) + } + pub fn add_entity(&mut self, entity_object: EntityObject) -> Result { let entity = entity_object.as_entity(); self.entities_to_add.push(entity_object);