rune/ast/
expr_tuple.rs
1use crate::ast::prelude::*;
2
3#[test]
4#[cfg(not(miri))]
5fn ast_parse() {
6 rt::<ast::ExprTuple>("()");
7 rt::<ast::ExprTuple>("(1,)");
8 rt::<ast::ExprTuple>("(1, \"two\")");
9 rt::<ast::ExprTuple>("(1, 2,)");
10 rt::<ast::ExprTuple>("(1, 2, foo())");
11}
12
13#[derive(Debug, TryClone, PartialEq, Eq, Parse, ToTokens, Spanned)]
17#[non_exhaustive]
18pub struct ExprTuple {
19 #[rune(iter, meta)]
21 pub attributes: Vec<ast::Attribute>,
22 pub items: ast::Parenthesized<ast::Expr, T![,]>,
24}
25
26impl ExprTuple {
27 pub(crate) fn parse_from_first_expr(
29 parser: &mut Parser<'_>,
30 attributes: Vec<ast::Attribute>,
31 open: ast::OpenParen,
32 expr: ast::Expr,
33 ) -> Result<Self> {
34 Ok(Self {
35 attributes,
36 items: ast::Parenthesized::parse_from_first(parser, open, expr)?,
37 })
38 }
39}