From 78ee1979599c6fc5ba535bc4b6c8b5dbb107d9cc Mon Sep 17 00:00:00 2001 From: Craig Roy Date: Wed, 8 May 2024 16:51:25 +0100 Subject: [PATCH] refactor: Common up Hugr::validate functions --- hugr/src/hugr/validate.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/hugr/src/hugr/validate.rs b/hugr/src/hugr/validate.rs index 7ca446d8c..40de5d805 100644 --- a/hugr/src/hugr/validate.rs +++ b/hugr/src/hugr/validate.rs @@ -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