pub struct Symbol<'s>(/* private fields */);Expand description
An interned identifier: an index into the SymbolStore that minted it,
branded with that store’s borrow lifetime.
Copy + Eq + Hash in one u32, so scope stacks, type environments and
the compiler’s lexical frames compare and hash identifiers by integer
instead of by string content.
Equality is index equality, which is exactly string equality for symbols
from the same store (the store deduplicates on intern). Comparing symbols
from two different stores is meaningless but not unsound — see
SymbolStore::resolve.
Ord is index order (insertion order), not lexicographic order. It
exists only so symbols can key a BTreeMap/BTreeSet for deterministic
iteration within one run. Anywhere the output depends on ordering (type
error text, record kinds, optional-label rows), sort by
SymbolStore::resolve text instead — see this module’s header.
Implementations§
Trait Implementations§
impl<'s> Copy for Symbol<'s>
Source§impl Debug for Symbol<'_>
Prints the index, not the text — a Symbol is a bare u32 plus a
zero-sized brand, so it has no way to reach its store from here.
impl Debug for Symbol<'_>
Prints the index, not the text — a Symbol is a bare u32 plus a
zero-sized brand, so it has no way to reach its store from here.
This is a deliberate choice: golden tests must diff
resolved strings produced at their format site, never Debug-of-AST.
impl<'s> Eq for Symbol<'s>
Source§impl<'s> Ord for Symbol<'s>
impl<'s> Ord for Symbol<'s>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<'s> PartialOrd for Symbol<'s>
impl<'s> PartialOrd for Symbol<'s>
impl<'s> StructuralPartialEq for Symbol<'s>
Auto Trait Implementations§
impl<'s> !RefUnwindSafe for Symbol<'s>
impl<'s> !Send for Symbol<'s>
impl<'s> !Sync for Symbol<'s>
impl<'s> !UnwindSafe for Symbol<'s>
impl<'s> Freeze for Symbol<'s>
impl<'s> Unpin for Symbol<'s>
impl<'s> UnsafeUnpin for Symbol<'s>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> Copy for Twhere
T: Copy,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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
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> ⓘ
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> ⓘ
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