Function clippy_utils::expr_or_init

source ·
pub fn expr_or_init<'a, 'b, 'tcx: 'b>(
    cx: &LateContext<'tcx>,
    expr: &'a Expr<'b>
) -> &'a Expr<'b>
Expand description

If the given expression is a local binding, find the initializer expression. If that initializer expression is another local binding, find its initializer again. This process repeats as long as possible (but usually no more than once). Initializer expressions with adjustments are ignored. If this is not desired, use find_binding_init instead.

Examples:

let abc = 1;
//        ^ output
let def = abc;
dbg!(def);
//   ^^^ input

// or...
let abc = 1;
let def = abc + 2;
//        ^^^^^^^ output
dbg!(def);
//   ^^^ input