summaryrefslogtreecommitdiff
path: root/engine-ecs/src/component.rs
diff options
context:
space:
mode:
Diffstat (limited to 'engine-ecs/src/component.rs')
-rw-r--r--engine-ecs/src/component.rs17
1 files changed, 9 insertions, 8 deletions
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<dyn Any>,
@@ -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<PairMemberMetadata>,
@@ -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<Cow<'static, str>>) -> Self
{
- self.name = name;
+ self.name = name.into();
self
}
@@ -391,7 +392,7 @@ impl Default for PartsBuilder
fn default() -> Self
{
Self {
- name: "(unspecified)",
+ name: "<unspecified>".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,
}