pub struct Symbol(/* private fields */);
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§
Source§impl 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§
Source§impl From<&NonZero<u16>> for Symbol
impl From<&NonZero<u16>> for Symbol
Source§fn from(sym: &NonZeroU16) -> Self
fn from(sym: &NonZeroU16) -> Self
Converts to this type from the input type.
Source§impl From<&NonZero<u32>> for Symbol
impl From<&NonZero<u32>> for Symbol
Source§fn from(sym: &NonZeroU32) -> Self
fn from(sym: &NonZeroU32) -> Self
Converts to this type from the input type.
Source§impl From<NonZero<u16>> for Symbol
impl From<NonZero<u16>> for Symbol
Source§fn from(sym: NonZeroU16) -> Self
fn from(sym: NonZeroU16) -> Self
Converts to this type from the input type.
Source§impl From<NonZero<u32>> for Symbol
impl From<NonZero<u32>> for Symbol
Source§fn from(sym: NonZeroU32) -> Self
fn from(sym: NonZeroU32) -> Self
Converts to this type from the input type.
Source§impl Ord for Symbol
impl Ord for Symbol
Source§impl PartialOrd for Symbol
impl PartialOrd for Symbol
Source§impl TryFrom<&NonZero<u64>> for Symbol
impl TryFrom<&NonZero<u64>> for Symbol
Source§type Error = SymbolOverflowError
type Error = SymbolOverflowError
The type returned in the event of a conversion error.
Source§impl TryFrom<&NonZero<usize>> for Symbol
impl TryFrom<&NonZero<usize>> for Symbol
Source§type Error = SymbolOverflowError
type Error = SymbolOverflowError
The type returned in the event of a conversion error.
Source§impl TryFrom<NonZero<u64>> for Symbol
impl TryFrom<NonZero<u64>> for Symbol
Source§type Error = SymbolOverflowError
type Error = SymbolOverflowError
The type returned in the event of a conversion error.
Source§impl TryFrom<NonZero<usize>> for Symbol
impl TryFrom<NonZero<usize>> for Symbol
Source§type Error = SymbolOverflowError
type Error = SymbolOverflowError
The type returned in the event of a conversion error.
impl Copy for Symbol
impl Eq for Symbol
impl StructuralPartialEq for Symbol
Auto Trait Implementations§
impl Freeze for Symbol
impl RefUnwindSafe for Symbol
impl Send for Symbol
impl Sync for Symbol
impl Unpin for Symbol
impl UnwindSafe for Symbol
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