clippy_utils

Function is_body_identity_function

source
pub(crate) fn is_body_identity_function(
    cx: &LateContext<'_>,
    func: &Body<'_>,
) -> bool
Expand description

Checks if a function’s body represents the identity function. Looks for bodies of the form:

  • |x| x
  • |x| return x
  • |x| { return x }
  • |x| { return x; }
  • |(x, y)| (x, y)

Consider calling is_expr_untyped_identity_function or is_expr_identity_function instead.