pub struct Symbol(/* private fields */);
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.
Implementations§
Source§impl Symbol
impl Symbol
Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Access the underlying string. This is a slowish operation because it requires locking the symbol interner.
Note that the lifetime of the return value is a lie. It’s not the same
as &self
, but actually tied to the lifetime of the underlying
interner. Interners are long-lived, and there are very few of them, and
this function is typically used for short-lived things, so in practice
it works out ok.
Sourcepub fn is_used_keyword(self) -> bool
pub fn is_used_keyword(self) -> bool
Returns true
if the symbol is a keyword used in the Solidity language.
For Yul keywords, use is_yul_keyword
.
Sourcepub fn is_unused_keyword(self) -> bool
pub fn is_unused_keyword(self) -> bool
Returns true
if the symbol is a keyword reserved for possible future use.
Sourcepub fn is_weak_keyword(self) -> bool
pub fn is_weak_keyword(self) -> bool
Returns true
if the symbol is a weak keyword and can be used in variable names.
Sourcepub fn is_yul_keyword(self) -> bool
pub fn is_yul_keyword(self) -> bool
Returns true
if the symbol is a keyword in a Yul context. Excludes EVM builtins.
Sourcepub fn is_yul_builtin(self) -> bool
pub fn is_yul_builtin(self) -> bool
Returns true
if the symbol is a Yul EVM builtin keyword.
Sourcepub fn is_reserved(self, yul: bool) -> bool
pub fn is_reserved(self, yul: bool) -> bool
Returns true
if the symbol is either a keyword, either currently in use or reserved for
possible future use.
Sourcepub fn is_non_reserved(self, yul: bool) -> bool
pub fn is_non_reserved(self, yul: bool) -> bool
Returns true
if the symbol is not a reserved keyword.
See is_reserved
.
Sourcepub fn is_elementary_type(self) -> bool
pub fn is_elementary_type(self) -> bool
Returns true
if the symbol is an elementary type name.
Note that this does not include [u]fixedMxN
types as they are not pre-interned.
Sourcepub fn is_bool_lit(self) -> bool
pub fn is_bool_lit(self) -> bool
Returns true
if the symbol is true
or false
.
Sourcepub fn is_location_specifier(self) -> bool
pub fn is_location_specifier(self) -> bool
Returns true
if the symbol is a location specifier.
Sourcepub fn is_mutability_specifier(self) -> bool
pub fn is_mutability_specifier(self) -> bool
Returns true
if the symbol is a mutability specifier.
Sourcepub fn is_visibility_specifier(self) -> bool
pub fn is_visibility_specifier(self) -> bool
Returns true
if the symbol is a visibility specifier.
Sourcepub const fn is_preinterned(self) -> bool
pub const fn is_preinterned(self) -> bool
Returns true
if the symbol was interned in the compiler’s symbols!
macro.
Trait Implementations§
Source§impl Key for Symbol
impl Key for Symbol
Source§fn into_usize(self) -> usize
fn into_usize(self) -> usize
usize
that represents the current keySource§fn try_from_usize(value: usize) -> Option<Self>
fn try_from_usize(value: usize) -> Option<Self>
usize
, returning None
if it failsSource§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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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