diff --git a/crates/bevy_core/src/name.rs b/crates/bevy_core/src/name.rs index f7d992e9c1..5e98d33631 100644 --- a/crates/bevy_core/src/name.rs +++ b/crates/bevy_core/src/name.rs @@ -68,12 +68,48 @@ impl Name { } } +impl std::fmt::Display for Name { + #[inline(always)] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + std::fmt::Display::fmt(&self.name, f) + } +} + +/* Conversions from strings */ + impl From<&str> for Name { #[inline(always)] fn from(name: &str) -> Self { Name::new(name.to_owned()) } } +impl From for Name { + #[inline(always)] + fn from(name: String) -> Self { + Name::new(name) + } +} + +/* Conversions to strings */ + +impl AsRef for Name { + #[inline(always)] + fn as_ref(&self) -> &str { + &self.name + } +} +impl From<&Name> for String { + #[inline(always)] + fn from(val: &Name) -> String { + val.as_str().to_owned() + } +} +impl From for String { + #[inline(always)] + fn from(val: Name) -> String { + val.name.into_owned() + } +} impl Hash for Name { fn hash(&self, state: &mut H) {