Enum rune::ast::Lit[][src]

pub enum Lit {
    Bool(LitBool),
    Byte(LitByte),
    Str(LitStr),
    ByteStr(LitByteStr),
    Char(LitChar),
    Number(LitNumber),
}

A literal value

Variants

Bool(LitBool)

A boolean literal

Byte(LitByte)

A byte literal

Str(LitStr)

A string literal

ByteStr(LitByteStr)

A byte string literal

Char(LitChar)

A character literal

Number(LitNumber)

A number literal

Implementations

impl Lit[src]

pub fn new<T>(lit: T) -> Self where
    T: IntoLit
[src]

Construct a new literal.

Panics

This will panic if it’s called outside of a macro context.

pub fn new_with<T>(lit: T, span: Span, storage: &Storage) -> Self where
    T: IntoLit
[src]

Construct a new literal with the specified span and storage.

This does not panic outside of a macro context, but requires access to the specified arguments.

Examples

use rune::{ast, Storage};
use runestick::Span;

let storage = Storage::default();
let string = ast::Lit::new_with("hello world", Span::empty(), &storage);

Trait Implementations

impl Clone for Lit[src]

impl Debug for Lit[src]

impl Eq for Lit[src]

impl Parse for Lit[src]

Parsing a Lit

Examples

use rune::{testing, ast};

testing::roundtrip::<ast::Lit>("true");
testing::roundtrip::<ast::Lit>("false");
testing::roundtrip::<ast::Lit>("'🔥'");
testing::roundtrip::<ast::Lit>("b'4'");
testing::roundtrip::<ast::Lit>("b\"bytes\"");
testing::roundtrip::<ast::Lit>("1.2");
testing::roundtrip::<ast::Lit>("42");
testing::roundtrip::<ast::Lit>("\"mary had a little lamb\"");

impl PartialEq<Lit> for Lit[src]

impl Spanned for Lit[src]

impl StructuralEq for Lit[src]

impl StructuralPartialEq for Lit[src]

impl ToTokens for Lit[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.