Skip to content

Commit

Permalink
refactor(hugr-core)!: declarative module behind optional feature flag (
Browse files Browse the repository at this point in the history
…#1341)

Closes #1340 

BREAKING CHANGE: `hugr::extension::declarative` now only available with
"declarative" feature
  • Loading branch information
ss2165 authored Jul 24, 2024
1 parent 67374ca commit 540eb23
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion hugr-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ workspace = true

[features]
extension_inference = []
declarative = ["serde_yaml"]

[dependencies]
portgraph = { workspace = true, features = ["serde", "petgraph"] }
Expand All @@ -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 }
Expand Down
2 changes: 2 additions & 0 deletions hugr-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions hugr-core/src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions hugr-core/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ pub fn try_collect_array<const N: usize, T>(
/// ```
///
/// From https://github.com/serde-rs/serde/issues/818.
#[allow(dead_code)]
pub(crate) fn is_default<T: Default + PartialEq>(t: &T) -> bool {
*t == Default::default()
}
Expand Down
3 changes: 2 additions & 1 deletion hugr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 2 additions & 0 deletions hugr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 540eb23

Please sign in to comment.