LitKind in rustc_ast::ast - Rust (original) (raw)

pub enum LitKind {
    Str(Symbol, StrStyle),
    ByteStr(Arc<[u8]>, StrStyle),
    CStr(Arc<[u8]>, StrStyle),
    Byte(u8),
    Char(char),
    Int(Pu128, LitIntType),
    Float(Symbol, LitFloatType),
    Bool(bool),
    Err(ErrorGuaranteed),
}

Expand description

This type is used within both ast::MetaItemLit and hir::Lit.

Note that the entire literal (including the suffix) is considered when deciding the LitKind. This means that float literals like 1f32 are classified by this type as Float. This is different to token::LitKindwhich does not consider the suffix.

§

A string literal ("foo"). The symbol is unescaped, and so may differ from the original token’s symbol.

§

A byte string (b"foo"). Not stored as a symbol because it might be non-utf8, and symbols only allow utf8 strings.

§

A C String (c"foo"). Guaranteed to only have \0 at the end.

§

A byte char (b'f').

§

A character literal ('a').

§

An integer literal (1).

§

A float literal (1.0, 1f64 or 1E10f64). The pre-suffix part is stored as a symbol rather than f64 so that LitKind can impl Eqand Hash.

§

A boolean literal (true, false).

§

Placeholder for a literal that wasn’t well-formed in some way.

Source§

Source

Converts literal token into a semantic literal.

Source§

Source

Source

Returns true if this literal is a string.

Source

Returns true if this literal is byte literal string.

Source

Returns true if this is a numeric literal.

Source

Returns true if this literal has no suffix. Note: this will return true for literals with prefixes such as raw strings and byte strings.

Source

Returns true if this literal has a suffix.

§

§

§

§

§

§

§

§

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: 24 bytes

Size for each variant: