Schedule + run all nodes in order. Consumes the graph because each node's `run` closure is `FnOnce`.
(self, ctx: &mut Ctx)
| 143 | /// Schedule + run all nodes in order. Consumes the graph because |
| 144 | /// each node's `run` closure is `FnOnce`. |
| 145 | pub fn execute(self, ctx: &mut Ctx) -> Result<(), GraphError> { |
| 146 | let order = schedule(&self.nodes)?; |
| 147 | // Drain in order. Using Option<PassNode> trick so we can take() |
| 148 | // nodes out by index without panicking the Vec's geometry. |
| 149 | let mut slots: Vec<Option<PassNode<'a, Ctx>>> = self.nodes.into_iter().map(Some).collect(); |
| 150 | for i in order { |
| 151 | let node = slots[i].take().expect("each node scheduled exactly once"); |
| 152 | (node.run)(ctx); |
| 153 | } |
| 154 | Ok(()) |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | impl<'a, Ctx> Default for Graph<'a, Ctx> { |