From 3c117bcd9455ffbcec5cd59dab37db0786e15e02 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 29 Nov 2026 21:16:11 +0100 Subject: feat(engine-ecs): change meaning of component name to type identifier --- engine-ecs/src/component.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'engine-ecs/src/component.rs') diff --git a/engine-ecs/src/component.rs b/engine-ecs/src/component.rs index d424e16..3e93930 100644 --- a/engine-ecs/src/component.rs +++ b/engine-ecs/src/component.rs @@ -1,4 +1,5 @@ use std::any::{Any, TypeId}; +use std::borrow::Cow; use std::fmt::Debug; use std::ops::{Deref, DerefMut}; @@ -32,7 +33,7 @@ pub trait Component: WithAssociatedId + SystemInput + Any + IntoParts Self: Sized; /// Returns the name of this component. - fn name(&self) -> &'static str; + fn name() -> Cow<'static, str>; } pub trait WithAssociatedId @@ -262,7 +263,7 @@ pub trait IntoParts pub struct Parts { pub id: Uid, - pub name: &'static str, + pub name: Cow<'static, str>, pub is_sole: bool, pub type_reflection: Option<&'static TypeReflection>, pub data: Box, @@ -286,7 +287,7 @@ impl Parts Self::builder() .type_reflection(component_info.type_reflection) - .name(component_info.name) + .name(component_info.name.clone()) .is_sole(component_info.is_sole) .build_with_any_data(id, data) } @@ -309,7 +310,7 @@ impl IntoParts for Parts #[derive(Debug)] pub struct PartsBuilder { - name: &'static str, + name: Cow<'static, str>, is_sole: bool, type_reflection: Option<&'static TypeReflection>, pair_relation_metadata: Option, @@ -319,9 +320,9 @@ pub struct PartsBuilder impl PartsBuilder { #[must_use] - pub fn name(mut self, name: &'static str) -> Self + pub fn name(mut self, name: impl Into>) -> Self { - self.name = name; + self.name = name.into(); self } @@ -391,7 +392,7 @@ impl Default for PartsBuilder fn default() -> Self { Self { - name: "(unspecified)", + name: "".into(), is_sole: false, type_reflection: None, pair_relation_metadata: None, @@ -406,7 +407,7 @@ pub struct Info { pub type_reflection: Option<&'static TypeReflection>, pub ty_id: TypeId, - pub name: &'static str, + pub name: Cow<'static, str>, pub is_sole: bool, } -- cgit v1.2.3-18-g5258