Skip to content

Commit

Permalink
refactor: Common up Hugr::validate functions
Browse files Browse the repository at this point in the history
  • Loading branch information
croyzor committed May 8, 2024
1 parent 9ae2290 commit 78ee197
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions hugr/src/hugr/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,12 @@ impl Hugr {
/// variables.
/// TODO: Add a version of validation which allows for open extension
/// variables (see github issue #457)
#[cfg(feature = "extension_inference")]
pub fn validate(&self, extension_registry: &ExtensionRegistry) -> Result<(), ValidationError> {
self.validate_with_extension_closure(HashMap::new(), extension_registry)
}

/// Check the validity of the HUGR, disregarding extension requirements.
#[cfg(not(feature = "extension_inference"))]
pub fn validate(&self, extension_registry: &ExtensionRegistry) -> Result<(), ValidationError> {
self.validate_no_extensions(extension_registry)
#[cfg(feature = "extension_inference")]
self.validate_with_extension_closure(HashMap::new(), extension_registry)?;
#[cfg(not(feature = "extension_inference"))]
self.validate_no_extensions(extension_registry)?;
Ok(())
}

/// Check the validity of the HUGR, but don't check consistency of extension
Expand Down

0 comments on commit 78ee197

Please sign in to comment.