clippy_utils

Function is_expr_identity_function

source
pub fn is_expr_identity_function(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool
Expand description

Checks if an expression represents the identity function Only examines closures and std::convert::identity

NOTE: If you want to use this function to find out if a closure is unnecessary, you likely want to call is_expr_untyped_identity_function instead, which makes sure that the closure doesn’t have type annotations. This is important because removing a closure with bindings can remove type information that helped type inference before, which can then lead to compile errors.