/// The control flow of visiting an edge during a graph traversal. pub enum VisitControlFlow { /// The traversal should continue on the outgoing edges of the given node. Continue(Node), /// The traversal should skip visiting the edges the given node. Skip(Node), /// The traversal should abort and return immediately. Abort(Abort), } impl VisitControlFlow { /// Map the continue and skip values of this control flow. pub fn map_node(self, mut map: Map) -> VisitControlFlow where Map: FnMut(Node) -> Mapped, { match self { VisitControlFlow::Continue(node) => VisitControlFlow::Continue(map(node)), VisitControlFlow::Skip(node) => VisitControlFlow::Skip(map(node)), VisitControlFlow::Abort(abort) => VisitControlFlow::Abort(abort), } } /// Map the abort value of this control flow. pub fn map_abort(self, mut map: Map) -> VisitControlFlow where Map: FnMut(Abort) -> Mapped, { match self { VisitControlFlow::Continue(node) => VisitControlFlow::Continue(node), VisitControlFlow::Skip(node) => VisitControlFlow::Skip(node), VisitControlFlow::Abort(abort) => VisitControlFlow::Abort(map(abort)), } } }