pub fn for_each_break_expr(
    label: Option<ast::Label>,
    body: Option<ast::BlockExpr>,
    cb: &mut dyn FnMut(ast::BreakExpr),
) {
    let label = label.and_then(|lbl| lbl.lifetime());
    let mut depth = 0;
    if let Some(b) = body {
        let preorder = &mut b.syntax().preorder();
        let ev_as_expr = |ev| match ev {
            WalkEvent::Enter(it) => Some(WalkEvent::Enter(ast::Expr::cast(it)?)),
            WalkEvent::Leave(it) => Some(WalkEvent::Leave(ast::Expr::cast(it)?)),
        };
        let eq_label = |lt: Option<ast::Lifetime>| {
            lt.zip(label.as_ref()).map_or(false, |(lt, lbl)| lt.text() == lbl.text())
        };
        while let Some(node) = preorder.find_map(ev_as_expr) {
            match node {
                WalkEvent::Enter(expr) => match expr {
                    ast::Expr::LoopExpr(_) | ast::Expr::WhileExpr(_) | ast::Expr::ForExpr(_) => {
                        depth += 1
                    }
                    ast::Expr::EffectExpr(e) if e.label().is_some() => depth += 1,
                    ast::Expr::BreakExpr(b)
                        if (depth == 0 && b.lifetime().is_none()) || eq_label(b.lifetime()) =>
                    {
                        cb(b);
                    }
                    _ => (),
                },
                WalkEvent::Leave(expr) => match expr {
                    ast::Expr::LoopExpr(_) | ast::Expr::WhileExpr(_) | ast::Expr::ForExpr(_) => {
                        depth -= 1
                    }
                    ast::Expr::EffectExpr(e) if e.label().is_some() => depth -= 1,
                    _ => (),
                },
            }
        }
    }
}
/// Calls `cb` on each break expr inside of `body` that is applicable for the given label.
Calls `cb` on each break expr inside of `body` that is applicable for the given label.
Calls ` cb ` on each break expr inside of ` body ` that is applicable for the given label .
pub fn for_each_break_expr(
    label: Option<ast::Label>,
    body: Option<ast::BlockExpr>,
    cb: &mut dyn FnMut(ast::BreakExpr),
) {
    let label = label.and_then(|lbl| lbl.lifetime());
    let mut depth = 0;
    if let Some(b) = body {
        let preorder = &mut b.syntax().preorder();
        let ev_as_expr = |ev| match ev {
            WalkEvent::Enter(it) => Some(WalkEvent::Enter(ast::Expr::cast(it)?)),
            WalkEvent::Leave(it) => Some(WalkEvent::Leave(ast::Expr::cast(it)?)),
        };
        let eq_label = |lt: Option<ast::Lifetime>| {
            lt.zip(label.as_ref()).map_or(false, |(lt, lbl)| lt.text() == lbl.text())
        };
        while let Some(node) = preorder.find_map(ev_as_expr) {
            match node {
                WalkEvent::Enter(expr) => match expr {
                    ast::Expr::LoopExpr(_) | ast::Expr::WhileExpr(_) | ast::Expr::ForExpr(_) => {
                        depth += 1
                    }
                    ast::Expr::EffectExpr(e) if e.label().is_some() => depth += 1,
                    ast::Expr::BreakExpr(b)
                        if (depth == 0 && b.lifetime().is_none()) || eq_label(b.lifetime()) =>
                    {
                        cb(b);
                    }
                    _ => (),
                },
                WalkEvent::Leave(expr) => match expr {
                    ast::Expr::LoopExpr(_) | ast::Expr::WhileExpr(_) | ast::Expr::ForExpr(_) => {
                        depth -= 1
                    }
                    ast::Expr::EffectExpr(e) if e.label().is_some() => depth -= 1,
                    _ => (),
                },
            }
        }
    }
}
pub fn for_each_break_expr ( label : Option < ast :: Label > , body : Option < ast :: BlockExpr > , cb : & mut dyn FnMut ( ast :: BreakExpr ) , ) { let label = label . and_then ( | lbl | lbl . lifetime ( ) ) ; let mut depth = 0 ; if let Some ( b ) = body { let preorder = & mut b . syntax ( ) . preorder ( ) ; let ev_as_expr = | ev | match ev { WalkEvent :: Enter ( it ) => Some ( WalkEvent :: Enter ( ast :: Expr :: cast ( it ) ? ) ) , WalkEvent :: Leave ( it ) => Some ( WalkEvent :: Leave ( ast :: Expr :: cast ( it ) ? ) ) , } ; let eq_label = | lt : Option < ast :: Lifetime > | { lt . zip ( label . as_ref ( ) ) . map_or ( false , | ( lt , lbl ) | lt . text ( ) == lbl . text ( ) ) } ; while let Some ( node ) = preorder . find_map ( ev_as_expr ) { match node { WalkEvent :: Enter ( expr ) => match expr { ast :: Expr :: LoopExpr ( _ ) | ast :: Expr :: WhileExpr ( _ ) | ast :: Expr :: ForExpr ( _ ) => { depth += 1 } ast :: Expr :: EffectExpr ( e ) if e . label ( ) . is_some ( ) => depth += 1 , ast :: Expr :: BreakExpr ( b ) if ( depth == 0 && b . lifetime ( ) . is_none ( ) ) || eq_label ( b . lifetime ( ) ) => { cb ( b ) ; } _ => ( ) , } , WalkEvent :: Leave ( expr ) => match expr { ast :: Expr :: LoopExpr ( _ ) | ast :: Expr :: WhileExpr ( _ ) | ast :: Expr :: ForExpr ( _ ) => { depth -= 1 } ast :: Expr :: EffectExpr ( e ) if e . label ( ) . is_some ( ) => depth -= 1 , _ => ( ) , } , } } } }
Calls `cb` on each break expr inside of `body` that is applicable for the given label.
Calls ` cb ` on each break expr inside of ` body ` that is applicable for the given label .
label
Option<ast::Label>
body
Option<ast::BlockExpr>
cb
&mut dyn FnMut(ast::BreakExpr)