Skip to content

Commit

Permalink
Remove derive as default feature
Browse files Browse the repository at this point in the history
  • Loading branch information
magnusuMET committed Jun 19, 2024
1 parent da40432 commit ff3a91a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ jobs:
- name: Check formatting
run: cargo fmt -- --check
- name: Documentation
run: cargo doc --workspace
run: cargo doc --workspace --features netcdf/derive
- name: Clippy
run: cargo clippy --workspace -- -D warnings
run: cargo clippy --features netcdf/derive --workspace -- -D warnings

test_apt:
name: test apt
Expand Down Expand Up @@ -71,10 +71,10 @@ jobs:
toolchain: ${{ matrix.rust }}

- name: Build
run: cargo build --verbose --workspace --exclude netcdf-src
run: cargo build --verbose --features netcdf/derive --workspace --exclude netcdf-src

- name: Test
run: cargo test --verbose --workspace --exclude netcdf-src --exclude netcdf-derive
run: cargo test --verbose --features netcdf/derive --workspace --exclude netcdf-src --exclude netcdf-derive

conda:
name: conda
Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:
export HDF5_DIR="$CONDA_PREFIX"
export NETCDF_DIR="$CONDA_PREFIX"
[ "${{runner.os}}" != "Windows" ] && export RUSTFLAGS="-C link-args=-Wl,-rpath,$CONDA_PREFIX/lib"
cargo test -vv --workspace --exclude netcdf-src --exclude netcdf-derive
cargo test -vv --workspace --exclude netcdf-src --exclude netcdf-derive --features netcdf/derive
static_builds:
name: static builds
Expand All @@ -131,7 +131,7 @@ jobs:
uses: dtolnay/rust-toolchain@stable
with: {toolchain: '${{matrix.rust}}'}
- name: Build and test
run: cargo test -vv --features static --workspace --exclude netcdf-derive
run: cargo test -vv --features netcdf/derive,static --workspace --exclude netcdf-derive

addr_san:
name: Address sanitizer
Expand All @@ -147,4 +147,4 @@ jobs:
env:
RUSTFLAGS: "-Z sanitizer=address"
RUSTDOCFLAGS: "-Z sanitizer=address"
run: cargo test --features netcdf-sys/static --target x86_64-unknown-linux-gnu --workspace --exclude netcdf-derive
run: cargo test --features netcdf-sys/static,netcdf/derive --target x86_64-unknown-linux-gnu --workspace --exclude netcdf-derive
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Supported:
* Open/Append/Create modes
* Reading from memory
* Unlimited dimensions
* User defined types (enum, compound, other types requires additional work)
* User defined types, using the feature `derive` (enum, compound, other types requires additional work)

Not (yet) supported (PRs welcome):
* Writing using memory-mapped file
Expand Down
2 changes: 1 addition & 1 deletion netcdf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exclude = ["examples/**", "tests/**"]
build = "build.rs"

[features]
default = ["ndarray", "derive"]
default = ["ndarray"]
static = ["netcdf-sys/static"]
derive = ["dep:netcdf-derive"]

Expand Down
21 changes: 21 additions & 0 deletions netcdf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,27 @@
//! var.put((11.., ..), values.view())?;
//! # Ok(()) }
//! ```
//!
//! How to derive `NcTypeDescriptor` for a custom type (requires `derive` feature flag).
//! See [NcTypeDescriptor] for additional examples.
//!
//! ```no_run
//! # #[cfg(not(feature = "derive"))]
//! # fn main() { /* This test does nothing without derive feature flag */ }
//! # #[cfg(feature = "derive")]
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! #[repr(C)]
//! #[derive(netcdf::NcType)]
//! struct Foo {
//! bar: f64,
//! baz: i64,
//! }
//! let mut file = netcdf::create("custom.nc")?;
//! file.add_type::<Foo>()?;
//! let mut var = file.add_variable::<Foo>("variable", &[])?;
//! var.put_value(Foo { bar: 1.0, baz: 2 }, ())?;
//! # Ok(()) }
//!

#![warn(missing_docs)]
#![allow(clippy::must_use_candidate)]
Expand Down
1 change: 1 addition & 0 deletions netcdf/tests/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ fn char() {
}

#[test]
#[cfg(feature = "derive")]
fn no_subtype() {
#[derive(netcdf::NcType)]
#[repr(C)]
Expand Down

0 comments on commit ff3a91a

Please sign in to comment.