(&self, graph: &Graph, annotation: GraphAnnotation)
| 4529 | } |
| 4530 | |
| 4531 | fn add_graph_annotation(&self, graph: &Graph, annotation: GraphAnnotation) -> Result<Context> { |
| 4532 | if graph.get_context() != *self { |
| 4533 | return Err(runtime_error!( |
| 4534 | "The graph to be annotated is in a different context" |
| 4535 | )); |
| 4536 | } |
| 4537 | if self.is_finalized() { |
| 4538 | return Err(runtime_error!( |
| 4539 | "Can't set a graph annotation in a finalized context" |
| 4540 | )); |
| 4541 | } |
| 4542 | let id = graph.get_id(); |
| 4543 | let mut cell = self.body.borrow_mut(); |
| 4544 | let annotations = cell.graphs_annotations.get_mut(&id); |
| 4545 | if let Some(annotation_vec) = annotations { |
| 4546 | annotation_vec.push(annotation); |
| 4547 | } else { |
| 4548 | cell.graphs_annotations.insert(id, vec![annotation]); |
| 4549 | } |
| 4550 | Ok(self.clone()) |
| 4551 | } |
| 4552 | |
| 4553 | fn get_graph_annotations(&self, graph: Graph) -> Result<Vec<GraphAnnotation>> { |
| 4554 | if graph.get_context() != *self { |
no test coverage detected