Skip to main content

Literal

Type Alias Literal 

Source
pub type Literal = Lit;
Expand description

Represents a parsed literal, including boolean keywords.

§Examples

use cel_parser::lex_lexer::{HasSpan, Literal};

let literal: Literal = syn::parse_str("true")?;
assert!(matches!(literal, Literal::Bool(ref b) if b.value));
let span = HasSpan::span(&literal);

Aliased Type§

pub enum Literal {
    Str(LitStr),
    ByteStr(LitByteStr),
    CStr(LitCStr),
    Byte(LitByte),
    Char(LitChar),
    Int(LitInt),
    Float(LitFloat),
    Bool(LitBool),
    Verbatim(Literal),
}

Variants§

§

Str(LitStr)

A UTF-8 string literal: "foo".

§

ByteStr(LitByteStr)

A byte string literal: b"foo".

§

CStr(LitCStr)

A nul-terminated C-string literal: c"foo".

§

Byte(LitByte)

A byte literal: b'f'.

§

Char(LitChar)

A character literal: 'a'.

§

Int(LitInt)

An integer literal: 1 or 1u16.

§

Float(LitFloat)

A floating point literal: 1f64 or 1.0e10f64.

Must be finite. May not be infinite or NaN.

§

Bool(LitBool)

A boolean literal: true or false.

§

Verbatim(Literal)

A raw token literal not interpreted by Syn.

Trait Implementations§

Source§

impl HasSpan for Literal

Source§

fn span(&self) -> Span

Returns the literal’s span, including uninterpreted verbatim literals.