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: NonZeroU32Implementations§
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 PartialOrd for Symbol
impl PartialOrd for Symbol
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more