Expand description
An AST literal.
Fields
token: Lit
The original literal token as written in source code.
kind: LitKind
The “semantic” representation of the literal lowered from the original tokens. Strings are unescaped, hexadecimal forms are eliminated, etc. FIXME: Remove this and only create the semantic representation during lowering to HIR.
span: Span
Implementations
sourceimpl Lit
impl Lit
sourcepub fn from_lit_token(token: Lit, span: Span) -> Result<Lit, LitError>
pub fn from_lit_token(token: Lit, span: Span) -> Result<Lit, LitError>
Converts literal token into an AST literal.
sourcepub fn from_token(token: &Token) -> Result<Lit, LitError>
pub fn from_token(token: &Token) -> Result<Lit, LitError>
Converts arbitrary token into an AST literal.
Keep this in sync with Token::can_begin_literal_or_bool
excluding unary negation.
sourcepub fn from_lit_kind(kind: LitKind, span: Span) -> Lit
pub fn from_lit_kind(kind: LitKind, span: Span) -> Lit
Attempts to recover an AST literal from semantic literal. This function is used when the original token doesn’t exist (e.g. the literal is created by an AST-based macro) or unavailable (e.g. from HIR pretty-printing).
Trait Implementations
sourceimpl<__CTX> HashStable<__CTX> for Lit where
__CTX: HashStableContext,
impl<__CTX> HashStable<__CTX> for Lit where
__CTX: HashStableContext,
fn hash_stable(&self, __hcx: &mut __CTX, __hasher: &mut StableHasher)
Auto Trait Implementations
impl RefUnwindSafe for Lit
impl !Send for Lit
impl !Sync for Lit
impl Unpin for Lit
impl UnwindSafe for Lit
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. 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: 48 bytes