rune/ast/
expr_loop.rs

1use crate::ast::prelude::*;
2
3#[test]
4#[cfg(not(miri))]
5fn ast_parse() {
6    rt::<ast::ExprLoop>("loop {}");
7    rt::<ast::ExprLoop>("loop { 1; }");
8    rt::<ast::ExprLoop>("'label: loop {1;}");
9    rt::<ast::ExprLoop>("#[attr] 'label: loop {x();}");
10}
11
12/// A `loop` expression.
13///
14/// * `loop { ... }`.
15#[derive(Debug, TryClone, PartialEq, Eq, Parse, ToTokens, Spanned)]
16#[rune(parse = "meta_only")]
17#[non_exhaustive]
18pub struct ExprLoop {
19    /// The attributes for the `loop`
20    #[rune(iter, meta)]
21    pub attributes: Vec<ast::Attribute>,
22    /// A label followed by a colon.
23    #[rune(iter, meta)]
24    pub label: Option<(ast::Label, T![:])>,
25    /// The `loop` keyword.
26    pub loop_token: T![loop],
27    /// The body of the loop.
28    pub body: Box<ast::Block>,
29}
30
31expr_parse!(Loop, ExprLoop, "loop expression");