Skip to content

Commit 4b38008

Browse files
authored
feat: Add HugrMut::insert(_view)_forest (#2518)
closes #2500, #2496 * New trait methods can insert several subtrees at once at different locations in target Hugr * trait-default-implement `insert_hugr`, `insert_view` and `insert_subgraph` using these Technically I think this is breaking, any external `impl HugrMut` now has to provide these new methods, but we believe implementations of HugrMut outside of hugr-core to be sufficiently rare not to justify a major-version-number release, and rs-semver-checks does not seem to pick up on this.
1 parent 38378dc commit 4b38008

6 files changed

Lines changed: 465 additions & 101 deletions

File tree

hugr-core/src/builder/build_traits.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ pub trait Container {
9999
}
100100

101101
/// Insert a copy of a HUGR as a child of the container.
102+
///
103+
/// Only the portion below the entrypoint will be inserted, with any incoming
104+
/// edges broken.
102105
fn add_hugr_view<H: HugrView>(&mut self, child: &H) -> InsertionResult<H::Node, Node> {
103106
let parent = self.container_node();
104107
self.hugr_mut().insert_from_view(parent, child)
@@ -256,7 +259,9 @@ pub trait Dataflow: Container {
256259
}
257260

258261
/// Copy a hugr-defined op into the sibling graph, wiring up the
259-
/// `input_wires` to the incoming ports of the resulting root node.
262+
/// `input_wires` to the incoming ports of the node that was the entrypoint.
263+
/// (Note, any part of `hugr` outside the entrypoint is not copied;
264+
/// this may lead to new input ports being disconnected.)
260265
///
261266
/// # Errors
262267
///

0 commit comments

Comments
 (0)