Skip to main content

find_ancestor

Function find_ancestor 

Source
pub fn find_ancestor<'a, F>(
    root: &'a Expression,
    target: &Expression,
    predicate: F,
) -> Option<&'a Expression>
where F: Fn(&Expression) -> bool,
Expand description

Find the first ancestor of target matching predicate, walking from parent toward root.

Uses pointer identity for target lookup. Returns None if no ancestor matches or target is not found in the tree.