From fb47933690dfb54206e9f136902671b19ddd34e0 Mon Sep 17 00:00:00 2001 From: HampusM Date: Tue, 22 Apr 2025 18:06:59 +0200 Subject: refactor(ecs): fix clippy lints --- ecs/src/entity.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'ecs/src/entity.rs') diff --git a/ecs/src/entity.rs b/ecs/src/entity.rs index 3f5a3d3..562f7ea 100644 --- a/ecs/src/entity.rs +++ b/ecs/src/entity.rs @@ -35,6 +35,14 @@ impl<'a> Handle<'a> self.entity.uid() } + /// Returns a reference to the specified component in this entity. `None` is + /// returned if the component isn't found in the entity. + /// + /// # Panics + /// Will panic if: + /// - The component's ID is not a component ID + /// - The component is mutably borrowed elsewhere + #[must_use] pub fn get(&self) -> Option> { assert_eq!(ComponentT::id().kind(), UidKind::Component); @@ -52,6 +60,14 @@ impl<'a> Handle<'a> ) } + /// Returns a mutable reference to the specified component in this entity. `None` is + /// returned if the component isn't found in the entity. + /// + /// # Panics + /// Will panic if: + /// - The component's ID is not a component ID + /// - The component is borrowed elsewhere + #[must_use] pub fn get_mut( &self, ) -> Option> @@ -131,7 +147,7 @@ macro_rules! static_entity { $crate::entity::CREATE_STATIC_ENTITIES )] #[linkme(crate=$crate::private::linkme)] - static CREATE_STATIC_ENTITY: fn(&$crate::World) = |world| { + static CREATE_STATIC_ENTITY: fn(&mut $crate::World) = |world| { world.create_entity_with_uid($components, *$ident); }; } @@ -141,4 +157,4 @@ macro_rules! static_entity { #[distributed_slice] #[doc(hidden)] -pub static CREATE_STATIC_ENTITIES: [fn(&World)]; +pub static CREATE_STATIC_ENTITIES: [fn(&mut World)]; -- cgit v1.2.3-18-g5258