is_expr_identity_of_pat

Function is_expr_identity_of_pat 

Source
pub fn is_expr_identity_of_pat(
    cx: &LateContext<'_>,
    pat: &Pat<'_>,
    expr: &Expr<'_>,
    by_hir: bool,
) -> bool
Expand description

Checks if the given expression is an identity representation of the given pattern:

  • x is the identity representation of x
  • (x, y) is the identity representation of (x, y)
  • [x, y] is the identity representation of [x, y]
  • Foo(bar, baz) is the identity representation of Foo(bar, baz)
  • Foo { bar, baz } is the identity representation of Foo { bar, baz }

Note that by_hir is used to determine bindings are checked by their HirId or by their name. This can be useful when checking patterns in let bindings or match arms.