Fix clippy lints in lister.rs
use ast::*;
pub fn list(rule: Rule) -> Rule {
- match rule {
- Rule { name, ty, expr } => Rule {
+ let Rule { name, ty, expr } = rule;
+ Rule {
name,
ty,
expr: expr.map_bottom_up(|expr| {
@@ -25,15 +25,9 @@ pub fn list(rule: Rule) -> Rule {
// Converts `(rule ~ rest)* ~ rule` to `rule ~ (rest ~ rule)*`,
// avoiding matching the last `rule` twice.
if l1 == r {
- Expr::Seq(
- l1,
- Box::new(Expr::Rep(Box::new(Expr::Seq(l2, r)))),
- )
+ Expr::Seq(l1, Box::new(Expr::Rep(Box::new(Expr::Seq(l2, r)))))
} else {
- Expr::Seq(
- Box::new(Expr::Rep(Box::new(Expr::Seq(l1, l2)))),
- r,
- )
+ Expr::Seq(Box::new(Expr::Rep(Box::new(Expr::Seq(l1, l2)))), r)
}
}
expr => Expr::Seq(Box::new(Expr::Rep(Box::new(expr))), r),
@@ -44,6 +38,5 @@ pub fn list(rule: Rule) -> Rule {
expr => expr,
}
}),
- },
}
}
