(&self, n: Node)
| 3449 | } |
| 3450 | |
| 3451 | fn remove_last_node(&self, n: Node) -> Result<()> { |
| 3452 | if n.get_graph() != *self { |
| 3453 | return Err(runtime_error!( |
| 3454 | "The node to be removed from a different graph" |
| 3455 | )); |
| 3456 | } |
| 3457 | { |
| 3458 | let cell = self.body.borrow(); |
| 3459 | if n != *cell |
| 3460 | .nodes |
| 3461 | .last() |
| 3462 | .ok_or_else(|| runtime_error!("Nodes list is empty"))? |
| 3463 | { |
| 3464 | return Err(runtime_error!( |
| 3465 | "The node to be removed is not the last node" |
| 3466 | )); |
| 3467 | } |
| 3468 | }; |
| 3469 | let context = self.get_context(); |
| 3470 | context.unregister_node(n.clone())?; |
| 3471 | let mut context_body = context.body.borrow_mut(); |
| 3472 | if let Some(tc) = &mut context_body.type_checker { |
| 3473 | tc.unregister_node(n)?; |
| 3474 | } |
| 3475 | let mut cell = self.body.borrow_mut(); |
| 3476 | cell.nodes.pop(); |
| 3477 | Ok(()) |
| 3478 | } |
| 3479 | |
| 3480 | pub(crate) fn nop(&self, a: Node) -> Result<Node> { |
| 3481 | self.add_node(vec![a], vec![], Operation::NOP) |
no test coverage detected