macro_rules! rules {
($($name:literal => $handler:expr),+ $(,)?) => { ... };
}Expand description
Define the rule half of a worm.
Each rule is a name and a handler. larvae calls a rule only on the nodes that
match the filter you declared in worm.toml. Thus undeclared kinds do not
cross the boundary.
ⓘ
larvae_worm::rules! {
"strip_debug" => |node: larvae_worm::Node| {
if node.kind() == "CallExpr" && node.text().starts_with("dprint") {
node.remove();
}
},
}Combine this macro with frontend! when a worm holds both roles.