rune/ast/
expr_lit.rs

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