diff --git a/crates/ruff_python_ast/src/helpers.rs b/crates/ruff_python_ast/src/helpers.rs index 522bdcd19b..e27ab6f450 100644 --- a/crates/ruff_python_ast/src/helpers.rs +++ b/crates/ruff_python_ast/src/helpers.rs @@ -114,10 +114,7 @@ where /// Call `func` over every `Expr` in `expr`, returning `true` if any expression /// returns `true`.. -pub fn any_over_expr(expr: &Expr, func: &F) -> bool -where - F: Fn(&Expr) -> bool, -{ +pub fn any_over_expr(expr: &Expr, func: &dyn Fn(&Expr) -> bool) -> bool { if func(expr) { return true; } @@ -248,10 +245,7 @@ where } } -pub fn any_over_type_param(type_param: &TypeParam, func: &F) -> bool -where - F: Fn(&Expr) -> bool, -{ +pub fn any_over_type_param(type_param: &TypeParam, func: &dyn Fn(&Expr) -> bool) -> bool { match type_param { TypeParam::TypeVar(ast::TypeParamTypeVar { bound, .. }) => bound .as_ref() @@ -261,10 +255,7 @@ where } } -pub fn any_over_pattern(pattern: &Pattern, func: &F) -> bool -where - F: Fn(&Expr) -> bool, -{ +pub fn any_over_pattern(pattern: &Pattern, func: &dyn Fn(&Expr) -> bool) -> bool { match pattern { Pattern::MatchValue(ast::PatternMatchValue { value, range: _ }) => { any_over_expr(value, func) @@ -300,10 +291,7 @@ where } } -pub fn any_over_stmt(stmt: &Stmt, func: &F) -> bool -where - F: Fn(&Expr) -> bool, -{ +pub fn any_over_stmt(stmt: &Stmt, func: &dyn Fn(&Expr) -> bool) -> bool { match stmt { Stmt::FunctionDef(ast::StmtFunctionDef { parameters, @@ -526,10 +514,7 @@ where } } -pub fn any_over_body(body: &[Stmt], func: &F) -> bool -where - F: Fn(&Expr) -> bool, -{ +pub fn any_over_body(body: &[Stmt], func: &dyn Fn(&Expr) -> bool) -> bool { body.iter().any(|stmt| any_over_stmt(stmt, func)) }