diff options
author | HampusM <hampus@hampusmat.com> | 2025-03-18 13:21:46 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2025-03-18 13:21:46 +0100 |
commit | 7a7d3a350b22b5555c27debff6fee4fc6100fa38 (patch) | |
tree | 9eb96f2563264f51691e2a06a7b95f8b39904d18 /ecs/src/component.rs | |
parent | ee7c0cb713891ae480407f56823289f3fe3b9807 (diff) |
Diffstat (limited to 'ecs/src/component.rs')
-rw-r--r-- | ecs/src/component.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/ecs/src/component.rs b/ecs/src/component.rs index f77b55a..77046d0 100644 --- a/ecs/src/component.rs +++ b/ecs/src/component.rs @@ -228,11 +228,13 @@ pub struct Metadata impl Metadata { + #[must_use] pub fn new_non_optional(id: Uid) -> Self { Self { id, is_optional: false } } + #[must_use] pub fn get<ComponentT: Component + ?Sized>(component: &ComponentT) -> Self { Self { @@ -241,6 +243,7 @@ impl Metadata } } + #[must_use] pub fn of<ComponentT: Component>() -> Self { Self { @@ -268,6 +271,10 @@ pub trait FromOptional<'comp> pub trait FromLockedOptional<'comp>: Sized { + /// Converts a reference to a optional locked boxed component to a instance of `Self`. + /// + /// # Errors + /// Returns `Err` if taking the lock (in a non-blocking way) fails. fn from_locked_optional_component( optional_component: Option<&'comp Lock<Box<dyn Component>>>, world: &'comp World, @@ -406,6 +413,5 @@ impl RefSequence for () _world: &'component World, ) -> Self::Handles<'component> { - () } } |