turbo_tasks/graph/
control_flow.rs

1/// The control flow of visiting an edge during a graph traversal.
2pub enum VisitControlFlow<Node, Abort = !> {
3    /// The traversal should continue on the outgoing edges of the given node.
4    Continue(Node),
5    /// The traversal should skip visiting the edges the given node.
6    Skip(Node),
7    /// The traversal should abort and return immediately.
8    Abort(Abort),
9}
10
11impl<Node, Abort> VisitControlFlow<Node, Abort> {
12    /// Map the continue and skip values of this control flow.
13    pub fn map_node<Map, Mapped>(self, mut map: Map) -> VisitControlFlow<Mapped, Abort>
14    where
15        Map: FnMut(Node) -> Mapped,
16    {
17        match self {
18            VisitControlFlow::Continue(node) => VisitControlFlow::Continue(map(node)),
19            VisitControlFlow::Skip(node) => VisitControlFlow::Skip(map(node)),
20            VisitControlFlow::Abort(abort) => VisitControlFlow::Abort(abort),
21        }
22    }
23
24    /// Map the abort value of this control flow.
25    pub fn map_abort<Map, Mapped>(self, mut map: Map) -> VisitControlFlow<Node, Mapped>
26    where
27        Map: FnMut(Abort) -> Mapped,
28    {
29        match self {
30            VisitControlFlow::Continue(node) => VisitControlFlow::Continue(node),
31            VisitControlFlow::Skip(node) => VisitControlFlow::Skip(node),
32            VisitControlFlow::Abort(abort) => VisitControlFlow::Abort(map(abort)),
33        }
34    }
35}