rune/ast/
expr_break.rs

1use crate::ast::prelude::*;
2
3#[test]
4#[cfg(not(miri))]
5fn ast_parse() {
6    rt::<ast::ExprBreak>("break");
7    rt::<ast::ExprBreak>("break 42");
8    rt::<ast::ExprBreak>("#[attr] break 42");
9}
10
11/// A break expression.
12///
13/// * `break [expr]`.
14#[derive(Debug, TryClone, PartialEq, Eq, Parse, ToTokens, Spanned)]
15#[rune(parse = "meta_only")]
16#[non_exhaustive]
17pub struct ExprBreak {
18    /// The attributes of the `break` expression
19    #[rune(iter, meta)]
20    pub attributes: Vec<ast::Attribute>,
21    /// The return token.
22    pub break_token: T![break],
23    /// A label to break to.
24    #[rune(iter)]
25    pub label: Option<ast::Label>,
26    /// An expression to break with.
27    #[rune(iter)]
28    pub expr: Option<Box<ast::Expr>>,
29}
30
31expr_parse!(Break, ExprBreak, "break expression");