From bc7505b2cfd94d62c5104ff50f2f5a1bb90cde10 Mon Sep 17 00:00:00 2001 From: Seyon Sivarajah Date: Wed, 24 Jul 2024 16:19:44 +0100 Subject: [PATCH 1/3] refactor(hugr-core)!: declarative behind optional feature flag BREAKING CHANGE: `hugr::extension::declarative` now only available with "declarative" feature --- hugr-core/Cargo.toml | 3 ++- hugr-core/src/extension.rs | 1 + hugr-core/src/utils.rs | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/hugr-core/Cargo.toml b/hugr-core/Cargo.toml index 5fd17aa38..341ad5295 100644 --- a/hugr-core/Cargo.toml +++ b/hugr-core/Cargo.toml @@ -18,6 +18,7 @@ workspace = true [features] extension_inference = [] +declarative = ["serde_yaml"] [dependencies] portgraph = { workspace = true, features = ["serde", "petgraph"] } @@ -28,7 +29,7 @@ num-rational = { workspace = true, features = ["serde"] } downcast-rs = { workspace = true } # Rc used here for Extension, but unfortunately we must turn the feature on globally serde = { workspace = true, features = ["derive", "rc"] } -serde_yaml = { workspace = true } +serde_yaml = { workspace = true, optional = true } typetag = { workspace = true } smol_str = { workspace = true, features = ["serde"] } derive_more = { workspace = true } diff --git a/hugr-core/src/extension.rs b/hugr-core/src/extension.rs index cec55ae69..65e74aae9 100644 --- a/hugr-core/src/extension.rs +++ b/hugr-core/src/extension.rs @@ -33,6 +33,7 @@ pub mod simple_op; pub use const_fold::{ConstFold, ConstFoldResult, Folder}; pub use prelude::{PRELUDE, PRELUDE_REGISTRY}; +#[cfg(feature = "declarative")] pub mod declarative; /// Extension Registries store extensions to be looked up e.g. during validation. diff --git a/hugr-core/src/utils.rs b/hugr-core/src/utils.rs index 3693743ea..4e2d15e99 100644 --- a/hugr-core/src/utils.rs +++ b/hugr-core/src/utils.rs @@ -96,6 +96,7 @@ pub fn try_collect_array( /// ``` /// /// From https://github.com/serde-rs/serde/issues/818. +#[allow(dead_code)] pub(crate) fn is_default(t: &T) -> bool { *t == Default::default() } From d53cbf2cad8da2c35429b6e2990ec22286da888a Mon Sep 17 00:00:00 2001 From: Seyon Sivarajah Date: Wed, 24 Jul 2024 16:39:46 +0100 Subject: [PATCH 2/3] add to readme --- hugr-core/README.md | 2 ++ hugr/README.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/hugr-core/README.md b/hugr-core/README.md index 2b45f92ec..d57d3cd70 100644 --- a/hugr-core/README.md +++ b/hugr-core/README.md @@ -19,6 +19,8 @@ Please read the [API documentation here][]. Experimental feature which allows automatic inference of extension usages and requirements in a HUGR and validation that extensions are correctly specified. Not enabled by default. +- `declarative`: + Experimental support for declaring extensions in YAML files, support is limited. ## Recent Changes diff --git a/hugr/README.md b/hugr/README.md index 88a61035b..d69091a2c 100644 --- a/hugr/README.md +++ b/hugr/README.md @@ -33,6 +33,8 @@ Please read the [API documentation here][]. Experimental feature which allows automatic inference of extension usages and requirements in a HUGR and validation that extensions are correctly specified. Not enabled by default. +- `declarative`: + Experimental support for declaring extensions in YAML files, support is limited. ## Recent Changes From 05e45e43013fe4ebb298959fd51cdc2f461d4fb2 Mon Sep 17 00:00:00 2001 From: Seyon Sivarajah Date: Wed, 24 Jul 2024 17:00:19 +0100 Subject: [PATCH 3/3] add features to hugr toml --- hugr/Cargo.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hugr/Cargo.toml b/hugr/Cargo.toml index ea05d95b5..988f42eff 100644 --- a/hugr/Cargo.toml +++ b/hugr/Cargo.toml @@ -22,7 +22,8 @@ bench = false path = "src/lib.rs" [features] -extension_inference = [] +extension_inference = ["hugr-core/extension_inference"] +declarative = ["hugr-core/declarative"] [dependencies] hugr-core = { path = "../hugr-core", version = "0.6.0" }