From c06d59ffa09e22a98647f5104944e1c13b161963 Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 5 Feb 2025 15:57:15 +0100 Subject: refactor(ecs): replace component::IsOptional enum with bool --- ecs/src/component.rs | 41 ++++++++++------------------------------- 1 file changed, 10 insertions(+), 31 deletions(-) (limited to 'ecs/src/component.rs') diff --git a/ecs/src/component.rs b/ecs/src/component.rs index b0423c5..f5aa0d1 100644 --- a/ecs/src/component.rs +++ b/ecs/src/component.rs @@ -51,20 +51,19 @@ pub trait Component: SystemInput + Any + TypeName #[doc(hidden)] fn as_any(&self) -> &dyn Any; - /// Whether the component `self` is optional. Returns the same value as - /// [`Component::is_optional`]. - fn self_is_optional(&self) -> IsOptional + /// Returns whether the component `self` is optional. + fn self_is_optional(&self) -> bool { - IsOptional::No + false } /// Returns whether this component is optional. #[must_use] - fn is_optional() -> IsOptional + fn is_optional() -> bool where Self: Sized, { - IsOptional::No + false } } @@ -139,14 +138,14 @@ where self } - fn self_is_optional(&self) -> IsOptional + fn self_is_optional(&self) -> bool { - Self::is_optional() + true } - fn is_optional() -> IsOptional + fn is_optional() -> bool { - IsOptional::Yes + true } } @@ -222,7 +221,7 @@ where pub struct Metadata { pub id: Uid, - pub is_optional: IsOptional, + pub is_optional: bool, } impl Metadata @@ -244,26 +243,6 @@ impl Metadata } } -/// Whether or not a `Component` is optional. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum IsOptional -{ - Yes, - No, -} - -impl From for IsOptional -{ - fn from(is_optional: bool) -> Self - { - if is_optional { - return IsOptional::Yes; - } - - IsOptional::No - } -} - pub trait FromOptionalMut<'comp> { fn from_optional_mut_component( -- cgit v1.2.3-18-g5258