Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 4 additions & 21 deletions hugr-core/src/hugr/views/sibling_subgraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl<N: HugrNode> SiblingSubgraph<N> {

/// Create a new convex sibling subgraph from input and output boundaries.
///
/// Provide a [`ConvexChecker`] instance to avoid constructing one for
/// Provide a [`TopoConvexChecker`] instance to avoid constructing one for
/// faster convexity check. If you do not have one, use
/// [`SiblingSubgraph::try_new`].
///
Expand Down Expand Up @@ -296,7 +296,7 @@ impl<N: HugrNode> SiblingSubgraph<N> {

/// Create a subgraph from a set of nodes.
///
/// Provide a [`ConvexChecker`] instance to avoid constructing one for
/// Provide a [`TopoConvexChecker`] instance to avoid constructing one for
/// faster convexity check. If you do not have one, use
/// [`SiblingSubgraph::try_from_nodes`].
///
Expand Down Expand Up @@ -494,7 +494,7 @@ impl<N: HugrNode> SiblingSubgraph<N> {
let checker_ref = match mode {
ValidationMode::WithChecker(c) => Some(c),
ValidationMode::CheckConvexity => {
checker = ConvexChecker::new(hugr, self.get_parent(hugr));
checker = TopoConvexChecker::new(hugr, self.get_parent(hugr));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ValidationMode::WithChecker specifically contains a TopoConvexChecker so this must match that

Some(&checker)
}
ValidationMode::SkipConvexity => None,
Expand Down Expand Up @@ -983,6 +983,7 @@ pub type LineConvexChecker<'g, Base> =
/// This type is generic over the convexity checker used. If checking convexity
/// for circuit-like graphs, use [`LineConvexChecker`], otherwise use
/// [`TopoConvexChecker`].
#[derive(Clone)]
pub struct ConvexChecker<'g, Base: HugrView, Checker> {
/// The base HUGR to check convexity on.
base: &'g Base,
Expand All @@ -993,16 +994,6 @@ pub struct ConvexChecker<'g, Base: HugrView, Checker> {
checker: OnceCell<(Checker, Base::RegionPortgraphNodes)>,
}

impl<'g, Base: HugrView, Checker: Clone> Clone for ConvexChecker<'g, Base, Checker> {
fn clone(&self) -> Self {
Self {
base: self.base,
region_parent: self.region_parent,
checker: self.checker.clone(),
}
}
}

impl<'g, Base: HugrView, Checker> ConvexChecker<'g, Base, Checker> {
/// Create a new convexity checker.
pub fn new(base: &'g Base, region_parent: Base::Node) -> Self {
Expand Down Expand Up @@ -1379,14 +1370,6 @@ fn is_non_value_edge<H: HugrView>(hugr: &H, node: H::Node, port: Port) -> bool {
is_other || is_static
}

impl<'a, 'c, G: HugrView, Checker: Clone> From<&'a ConvexChecker<'c, G, Checker>>
for std::borrow::Cow<'a, ConvexChecker<'c, G, Checker>>
{
fn from(value: &'a ConvexChecker<'c, G, Checker>) -> Self {
Self::Borrowed(value)
}
}

/// Errors that can occur while constructing a [`SimpleReplacement`].
#[derive(Debug, Clone, PartialEq, Error)]
#[non_exhaustive]
Expand Down
Loading