Struct rustc_span::symbol::Symbol [−][src]
pub struct Symbol(SymbolIndex);Expand description
An interned string.
Internally, a Symbol is implemented as an index, and all operations
(including hashing, equality, and ordering) operate on that index. The use
of rustc_index::newtype_index! means that Option<Symbol> only takes up 4 bytes,
because rustc_index::newtype_index! reserves the last 256 values for tagging purposes.
Note that Symbol cannot directly be a rustc_index::newtype_index! because it
implements fmt::Debug, Encodable, and Decodable in special ways.
Tuple Fields
0: SymbolIndexImplementations
Convert to a SymbolStr. This is a slowish operation because it
requires locking the symbol interner.
This method is supposed to be used in error messages, so it’s expected to be
identical to printing the original identifier token written in source code
(token_to_string, Ident::to_string), except that symbols don’t keep the rawness flag
or edition, so we have to guess the rawness using the global edition.
A keyword or reserved identifier that can be used as a path segment.
Returns true if the symbol is true or false.
Returns true if this symbol can be a raw identifier.
Trait Implementations
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for Symbol
impl UnwindSafe for Symbol
Blanket Implementations
Mutably borrows from an owned value. Read more
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 4 bytes