Skip to main content

walk_by

Function walk_by 

Source
pub fn walk_by<N, K: Eq + Hash, E>(
    start: N,
    key: impl Fn(&N) -> K,
    next: impl FnMut(&N) -> Result<Option<N>, E>,
) -> Result<Walk<N>, E>
Expand description

Walks from start along next: the node after each, or None where there is none. Nodes are told apart by key: a node with the key of the start closes the chain, one with the key of a node walked since runs into it. next is asked once for each node, in order, so it may keep state of its own.