pub enum LitKind<'ast> {
Str(StrKind, ByteSymbol, &'ast [(Span, Symbol)]),
Number(Uint<256, 4>),
Rational(Ratio<Uint<256, 4>>),
Address(Address),
Bool(bool),
Err(ErrorGuaranteed),
}Expand description
A kind of literal.
Variants§
Str(StrKind, ByteSymbol, &'ast [(Span, Symbol)])
A string, unicode string, or hex string literal. Contains the kind and the unescaped contents of the string.
Note that even if this is a string or unicode string literal, invalid UTF-8 sequences
are allowed, and as such this cannot be a str or Symbol.
The [(Span, Symbol)] contains the extra string literals of the same kind that were
concatenated together to form this literal.
For example, "foo" "bar" would be parsed as:
Lit {
span: 0..11,
symbol: "foo",
kind: Str("foobar", [(6..11, "bar")]),
}This list is only present in the AST, and is discarded after.
Number(Uint<256, 4>)
A decimal or hexadecimal number literal.
Rational(Ratio<Uint<256, 4>>)
A rational number literal.
Note that rational literals that evaluate to integers are represented as
Number (e.g. 1.2e3 is represented as Number(1200)).
Address(Address)
An address literal. This is a special case of a 40 digit hexadecimal number literal.
Bool(bool)
A boolean literal.
Err(ErrorGuaranteed)
An error occurred while parsing the literal, which has been emitted.
Implementations§
Trait Implementations§
impl<'ast> Copy for LitKind<'ast>
Auto Trait Implementations§
impl<'ast> Freeze for LitKind<'ast>
impl<'ast> RefUnwindSafe for LitKind<'ast>
impl<'ast> Send for LitKind<'ast>
impl<'ast> Sync for LitKind<'ast>
impl<'ast> Unpin for LitKind<'ast>
impl<'ast> UnwindSafe for LitKind<'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