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 27 28 29 30 31
use crate::ast; use crate::{Parse, Spanned, ToTokens}; /// A `loop` expression: `loop { ... }`. /// /// # Examples /// /// ```rust /// use rune::{testing, ast}; /// /// testing::roundtrip::<ast::ExprLoop>("loop {}"); /// testing::roundtrip::<ast::ExprLoop>("loop { 1; }"); /// testing::roundtrip::<ast::ExprLoop>("'label: loop {1;}"); /// testing::roundtrip::<ast::ExprLoop>("#[attr] 'label: loop {x();}"); /// ``` #[derive(Debug, Clone, PartialEq, Eq, Parse, ToTokens, Spanned)] #[rune(parse = "meta_only")] pub struct ExprLoop { /// The attributes for the `loop` #[rune(iter, meta)] pub attributes: Vec<ast::Attribute>, /// A label followed by a colon. #[rune(iter, meta)] pub label: Option<(ast::Label, T![:])>, /// The `loop` keyword. pub loop_token: T![loop], /// The body of the loop. pub body: Box<ast::Block>, } expr_parse!(Loop, ExprLoop, "loop expression");