1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
use crate::ast::prelude::*;
/// A literal expression. With the addition of being able to receive attributes,
/// this is identical to [ast::Lit].
///
/// # Examples
///
/// ```
/// use rune::{ast, testing};
///
/// testing::roundtrip::<ast::ExprLit>("42");
/// testing::roundtrip::<ast::ExprLit>("\"test\"");
/// testing::roundtrip::<ast::ExprLit>("#[attr] 42");
/// ```
#[derive(Debug, Clone, PartialEq, Eq, Parse, ToTokens, Spanned)]
#[rune(parse = "meta_only")]
#[non_exhaustive]
pub struct ExprLit {
/// Attributes associated with the literal expression.
#[rune(iter, meta)]
pub attributes: Vec<ast::Attribute>,
/// The literal in the expression.
pub lit: ast::Lit,
}
expr_parse!(Lit, ExprLit, "literal expression");