Struct stylecs::StaticName
source · pub struct StaticName { /* private fields */ }
Expand description
A statically defined Name
.
Creating a static private name
use stylecs::{static_name, Name, StaticName};
static PRIVATE: StaticName = static_name!("private");
assert_eq!(PRIVATE.to_name(), Name::private("private").unwrap());
Why use StaticName
?
This type enables a minor optimization. Each Identifier
guarantees that
only one copy of the string it points to exists. This allows for
optimizations when using names as keys in a hash map. To support this, each
time an Identifier
is created, the global list must be first checked and
a copy of the existing value returned if it already exists.
This type allows performing this initialization once upon first access of
the StaticName
. This type can be converted to Name
using
Into
/From
.
Implementations§
Trait Implementations§
source§impl<'a> From<&'a StaticName> for Name
impl<'a> From<&'a StaticName> for Name
source§fn from(value: &'a StaticName) -> Self
fn from(value: &'a StaticName) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl RefUnwindSafe for StaticName
impl Send for StaticName
impl Sync for StaticName
impl Unpin for StaticName
impl UnwindSafe for StaticName
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more