diff options
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> { - () } } |