pub struct Lit<'ast> {
pub span: Span,
pub symbol: Symbol,
pub kind: LitKind<'ast>,
}Expand description
A literal: hex"1234", 5.6 ether.
Note that multiple string literals of the same kind are concatenated together to form a single
Lit (see LitKind::Str), thus the span will be the span of the entire literal, and
the symbol will be the concatenated string.
Reference: https://docs.soliditylang.org/en/latest/grammar.html#a4.SolidityParser.literal
Fields§
§span: SpanThe concatenated span of the literal.
symbol: SymbolThe original contents of the literal as written in the source code, excluding any quotes.
If this is a concatenated string literal, this will contain only the first string
literal’s contents. For all the other string literals, see the extra field in
LitKind::Str.
kind: LitKind<'ast>The “semantic” representation of the literal lowered from the original tokens. Strings are unescaped and concatenated, hexadecimal forms are eliminated, etc.
Implementations§
Source§impl Lit<'_>
impl Lit<'_>
Sourcepub fn first_span(&self) -> Span
pub fn first_span(&self) -> Span
Returns the span of the first string literal in this literal.
Sourcepub fn literals(&self) -> impl Iterator<Item = (Span, Symbol)>
pub fn literals(&self) -> impl Iterator<Item = (Span, Symbol)>
Returns an iterator over all the literals that were concatenated to form this literal.
Sourcepub fn copy_without_data<'a>(&self) -> Lit<'a>
pub fn copy_without_data<'a>(&self) -> Lit<'a>
Returns a copy of this literal with any allocated data discarded.
Trait Implementations§
impl<'ast> Copy for Lit<'ast>
Auto Trait Implementations§
impl<'ast> Freeze for Lit<'ast>
impl<'ast> RefUnwindSafe for Lit<'ast>
impl<'ast> Send for Lit<'ast>
impl<'ast> Sync for Lit<'ast>
impl<'ast> Unpin for Lit<'ast>
impl<'ast> UnwindSafe for Lit<'ast>
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<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