#[repr(transparent)]pub struct Symbol(_);
Expand description
Identifier bound to an interned string.
SymbolTable
is guaranteed to return an equivalent Symbol
each time
an equivalent string is interned.
A Symbol
allows retrieving a reference to the original interned string.
Symbol
s are based on a u32
index.
Symbol
s are not constrained to the SymbolTable
which created them. No
runtime checks ensure that SymbolTable::get
is called with a Symbol
that the table itself issued.
Implementations
sourceimpl Symbol
impl Symbol
sourcepub const fn new(sym: u32) -> Self
pub const fn new(sym: u32) -> Self
Construct a new Symbol
from the given u32
.
Symbol
s constructed outside a SymbolTable
may fail to resolve to
an underlying string using SymbolTable::get
.
Symbol
s are not constrained to the SymbolTable
which created them.
No runtime checks ensure that SymbolTable::get
is called with a
Symbol
that the table itself issued.
Examples
let sym = Symbol::new(263);
assert_eq!(263, sym.id());
Trait Implementations
sourceimpl From<&'_ NonZeroU16> for Symbol
impl From<&'_ NonZeroU16> for Symbol
sourcefn from(sym: &NonZeroU16) -> Self
fn from(sym: &NonZeroU16) -> Self
Converts to this type from the input type.
sourceimpl From<&'_ NonZeroU32> for Symbol
impl From<&'_ NonZeroU32> for Symbol
sourcefn from(sym: &NonZeroU32) -> Self
fn from(sym: &NonZeroU32) -> Self
Converts to this type from the input type.
sourceimpl From<NonZeroU16> for Symbol
impl From<NonZeroU16> for Symbol
sourcefn from(sym: NonZeroU16) -> Self
fn from(sym: NonZeroU16) -> Self
Converts to this type from the input type.
sourceimpl From<NonZeroU32> for Symbol
impl From<NonZeroU32> for Symbol
sourcefn from(sym: NonZeroU32) -> Self
fn from(sym: NonZeroU32) -> Self
Converts to this type from the input type.
sourceimpl Ord for Symbol
impl Ord for Symbol
sourceimpl PartialOrd<Symbol> for Symbol
impl PartialOrd<Symbol> for Symbol
sourcefn partial_cmp(&self, other: &Symbol) -> Option<Ordering>
fn partial_cmp(&self, other: &Symbol) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl TryFrom<&'_ NonZeroU64> for Symbol
impl TryFrom<&'_ NonZeroU64> for Symbol
type Error = SymbolOverflowError
type Error = SymbolOverflowError
The type returned in the event of a conversion error.
sourcefn try_from(value: &NonZeroU64) -> Result<Self, Self::Error>
fn try_from(value: &NonZeroU64) -> Result<Self, Self::Error>
Performs the conversion.
sourceimpl TryFrom<&'_ NonZeroUsize> for Symbol
impl TryFrom<&'_ NonZeroUsize> for Symbol
type Error = SymbolOverflowError
type Error = SymbolOverflowError
The type returned in the event of a conversion error.
sourcefn try_from(value: &NonZeroUsize) -> Result<Self, Self::Error>
fn try_from(value: &NonZeroUsize) -> Result<Self, Self::Error>
Performs the conversion.
sourceimpl TryFrom<NonZeroU64> for Symbol
impl TryFrom<NonZeroU64> for Symbol
type Error = SymbolOverflowError
type Error = SymbolOverflowError
The type returned in the event of a conversion error.
sourcefn try_from(value: NonZeroU64) -> Result<Self, Self::Error>
fn try_from(value: NonZeroU64) -> Result<Self, Self::Error>
Performs the conversion.
sourceimpl TryFrom<NonZeroUsize> for Symbol
impl TryFrom<NonZeroUsize> for Symbol
type Error = SymbolOverflowError
type Error = SymbolOverflowError
The type returned in the event of a conversion error.
sourcefn try_from(value: NonZeroUsize) -> Result<Self, Self::Error>
fn try_from(value: NonZeroUsize) -> Result<Self, Self::Error>
Performs the conversion.
impl Copy for Symbol
impl Eq for Symbol
impl StructuralEq for Symbol
impl StructuralPartialEq for Symbol
Auto Trait Implementations
impl RefUnwindSafe for Symbol
impl Send for Symbol
impl Sync for Symbol
impl Unpin for Symbol
impl UnwindSafe for Symbol
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more