Macro match_ast
Source macro_rules! match_ast {
(@arms($node:tt)
$( $path:ident )::+ ($it:pat)
$(if $guard:expr)?
=> $res:expr
$(, $($t:tt)*)?
) => { ... };
(@arms($node:expr) _ => $catch_all:expr $(,)?) => { ... };
(match $node:tt {$($t:tt)+}) => { ... };
($i:ident $expr:tt) => { ... };
(match $expr:tt {}) => { ... };
}
Expand description
Match AST AstNode::cast()
§Examples
ⓘmatch_ast!{match node {
grammar::Rule(rule) => rule.name(),
grammar::Slice(slice) => slice.name(),
_ => unnamed(),
}}