clippy_utils::visitors

Function for_each_value_source

source
pub fn for_each_value_source<'tcx, B>(
    e: &'tcx Expr<'tcx>,
    f: &mut impl FnMut(&'tcx Expr<'tcx>) -> ControlFlow<B>,
) -> ControlFlow<B>
Expand description

Runs the given function for each sub-expression producing the final value consumed by the parent of the give expression.

e.g. for the following expression

if foo {
    f(0)
} else {
    1 + 1
}

this will pass both f(0) and 1+1 to the given function.