Skip to content

Commit

Permalink
feat: HugrMut::remove_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q committed Oct 30, 2024
1 parent fed74b5 commit 2c6664b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions hugr-core/src/hugr/hugrmut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ pub trait HugrMut: HugrMutInternals {
*entry = metadata.into();
}

/// Remove a metadata entry associated with a node.
///
/// # Panics
///
/// If the node is not in the graph.
fn remove_metadata(&mut self, node: Node, key: impl AsRef<str>) {
panic_invalid_node(self, node);
let node_meta = self.hugr_mut().metadata.get_mut(node.pg_index());
if let Some(node_meta) = node_meta {
node_meta.remove(key.as_ref());
}
}

/// Retrieve the complete metadata map for a node.
fn take_node_metadata(&mut self, node: Node) -> Option<NodeMetadataMap> {
if !self.valid_node(node) {
Expand Down

0 comments on commit 2c6664b

Please sign in to comment.