summaryrefslogtreecommitdiff
path: root/ecs/src/entity.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2025-04-22 18:06:59 +0200
committerHampusM <hampus@hampusmat.com>2025-04-22 18:06:59 +0200
commitfb47933690dfb54206e9f136902671b19ddd34e0 (patch)
treeffdb6640ea896b69b0267a9526657b9ed454184f /ecs/src/entity.rs
parentd9ac86a1f6ec541a399794f9f81381753cfea5f6 (diff)
refactor(ecs): fix clippy lints
Diffstat (limited to 'ecs/src/entity.rs')
-rw-r--r--ecs/src/entity.rs20
1 files changed, 18 insertions, 2 deletions
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<ComponentT: Component>(&self) -> Option<ComponentHandle<'_, ComponentT>>
{
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<ComponentT: Component>(
&self,
) -> Option<ComponentHandleMut<'_, ComponentT>>
@@ -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)];