pub struct Symbol(NonZeroU32);
Expand description
An interned string.
Represented as an index internally, with all operations based on that.
A Symbol
reserves the value 0
, so that Option<Symbol>
only takes up 4 bytes.
Tuple Fields§
§0: NonZeroU32
Implementations§
source§impl Symbol
impl Symbol
sourcepub fn as_str<R>(self, s: &SessionGlobals, with: impl FnOnce(&str) -> R) -> R
pub fn as_str<R>(self, s: &SessionGlobals, with: impl FnOnce(&str) -> R) -> R
Convert to effectively a &'static str
given the SessionGlobals
.
fn serde_to_symbol<'de, D: Deserializer<'de>>( de: D, ) -> Result<NonZeroU32, D::Error>
fn serde_from_symbol<S: Serializer>( index: &NonZeroU32, ser: S, ) -> Result<S::Ok, S::Error>
Trait Implementations§
source§impl<'de> Deserialize<'de> for Symbol
impl<'de> Deserialize<'de> for Symbol
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Ord for Symbol
impl Ord for Symbol
source§impl PartialEq for Symbol
impl PartialEq for Symbol
source§impl PartialOrd for Symbol
impl PartialOrd for Symbol
1.0.0 · source§fn 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 moreimpl 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
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.