Skip to main content

find_cycle

Function find_cycle 

Source
pub fn find_cycle(
    start: EntityId,
    max_depth: usize,
    successors: impl FnMut(EntityId) -> Vec<EntityId>,
) -> Option<Vec<EntityId>>
Expand description

Find one cycle reachable from start, if any.

Returns the path from the first repeated entity back to itself, so the caller can name the entities involved in a diagnostic. Bounded by max_depth so a pathological file cannot spin.