Skip to content

Commit

Permalink
Undo special casing try_from_nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q committed Nov 14, 2024
1 parent e057877 commit 68d2a59
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions hugr-core/src/hugr/views/sibling_subgraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,8 @@ impl SiblingSubgraph {
nodes: impl Into<Vec<Node>>,
hugr: &impl HugrView,
) -> Result<Self, InvalidSubgraph> {
let nodes = nodes.into();
match nodes.len() {
0 => Err(InvalidSubgraph::EmptySubgraph),
1 => Ok(Self::from_node(nodes[0], hugr)),
_ => {
let checker = TopoConvexChecker::new(hugr);
Self::try_from_nodes_with_checker(nodes, hugr, &checker)
}
}
let checker = TopoConvexChecker::new(hugr);
Self::try_from_nodes_with_checker(nodes, hugr, &checker)
}

/// Create a subgraph from a set of nodes.
Expand Down Expand Up @@ -290,7 +283,8 @@ impl SiblingSubgraph {
let nodes = vec![node];
let inputs = hugr
.node_inputs(node)
.filter_map(|p| hugr.is_linked(node, p).then(|| vec![(node, p)]))
.filter(|&p| hugr.is_linked(node, p))
.map(|p| vec![(node, p)])
.collect_vec();
let outputs = hugr
.node_outputs(node)
Expand Down

0 comments on commit 68d2a59

Please sign in to comment.