diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f8cf271..538af1e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Move sync stores to `storage::store::sync` - Move sync storage traits to `storage_sync.rs` - Move array sync storage trait impls into `array_sync.rs` + - Use `required-features` for examples ## [0.6.0] - 2023-11-16 diff --git a/Cargo.toml b/Cargo.toml index 57514662..0b2ed947 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -74,6 +74,34 @@ criterion = "0.5.1" tempfile = "3" tokio = { version = "1.34.0", features = ["macros", "rt-multi-thread"] } +[[example]] +name = "array_write_read" +required-features = ["ndarray"] + +[[example]] +name = "async_array_write_read" +required-features = ["ndarray", "async"] + +[[example]] +name = "async_http_array_read" +required-features = ["ndarray", "async", "http"] + +[[example]] +name = "http_array_read" +required-features = ["ndarray", "http"] + +[[example]] +name = "rectangular_array_write_read" +required-features = ["ndarray"] + +[[example]] +name = "sharded_array_write_read" +required-features = ["ndarray", "sharding"] + +[[example]] +name = "zip_array_write_read" +required-features = ["ndarray", "zip"] + [[bench]] name = "array_subset" harness = false diff --git a/examples/array_write_read.rs b/examples/array_write_read.rs index 3eb22026..142318ad 100644 --- a/examples/array_write_read.rs +++ b/examples/array_write_read.rs @@ -1,4 +1,3 @@ -#[cfg(feature = "ndarray")] fn array_write_read() -> Result<(), Box> { use rayon::prelude::{IntoParallelIterator, ParallelIterator}; use std::sync::Arc; @@ -121,11 +120,6 @@ fn array_write_read() -> Result<(), Box> { Ok(()) } -#[cfg(not(feature = "ndarray"))] -fn array_write_read() -> Result<(), Box> { - panic!("the array_write_read example requires the ndarray feature") -} - fn main() { if let Err(err) = array_write_read() { println!("{}", err); diff --git a/examples/async_array_write_read.rs b/examples/async_array_write_read.rs index 654be936..65ad71a5 100644 --- a/examples/async_array_write_read.rs +++ b/examples/async_array_write_read.rs @@ -1,4 +1,3 @@ -#[cfg(feature = "ndarray")] async fn async_array_write_read() -> Result<(), Box> { use futures::{stream::FuturesUnordered, StreamExt}; use std::sync::Arc; @@ -140,11 +139,6 @@ async fn async_array_write_read() -> Result<(), Box> { Ok(()) } -#[cfg(not(feature = "ndarray"))] -async fn async_array_write_read() -> Result<(), Box> { - panic!("the async_array_write_read example requires the ndarray feature") -} - #[tokio::main] async fn main() { if let Err(err) = async_array_write_read().await { diff --git a/examples/async_http_array_read.rs b/examples/async_http_array_read.rs index 92638cd3..44645673 100644 --- a/examples/async_http_array_read.rs +++ b/examples/async_http_array_read.rs @@ -1,4 +1,3 @@ -#[cfg(all(feature = "ndarray", feature = "async"))] async fn http_array_read() -> Result<(), Box> { use std::sync::Arc; use zarrs::{ @@ -58,11 +57,6 @@ async fn http_array_read() -> Result<(), Box> { Ok(()) } -#[cfg(any(not(feature = "ndarray"), not(feature = "async")))] -async fn http_array_read() -> Result<(), Box> { - panic!("the async_http_array_read example requires the ndarray and async features") -} - #[tokio::main] async fn main() { if let Err(err) = http_array_read().await { diff --git a/examples/http_array_read.rs b/examples/http_array_read.rs index 7067b2fc..e75484b5 100644 --- a/examples/http_array_read.rs +++ b/examples/http_array_read.rs @@ -1,4 +1,3 @@ -#[cfg(feature = "ndarray")] fn http_array_read() -> Result<(), Box> { use std::sync::Arc; use zarrs::{ @@ -52,11 +51,6 @@ fn http_array_read() -> Result<(), Box> { Ok(()) } -#[cfg(not(feature = "ndarray"))] -fn http_array_read() -> Result<(), Box> { - panic!("the http_array_read example requires the ndarray feature") -} - fn main() { if let Err(err) = http_array_read() { println!("{}", err); diff --git a/examples/rectangular_array_write_read.rs b/examples/rectangular_array_write_read.rs index 5612e939..98c5deba 100644 --- a/examples/rectangular_array_write_read.rs +++ b/examples/rectangular_array_write_read.rs @@ -1,4 +1,3 @@ -#[cfg(feature = "ndarray")] fn rectangular_array_write_read() -> Result<(), Box> { use rayon::prelude::{IntoParallelIterator, ParallelIterator}; use zarrs::array::ChunkGrid; @@ -123,11 +122,6 @@ fn rectangular_array_write_read() -> Result<(), Box> { Ok(()) } -#[cfg(not(feature = "ndarray"))] -fn rectangular_array_write_read() -> Result<(), Box> { - panic!("the rectangular_array_write_read example requires the ndarray feature") -} - fn main() { if let Err(err) = rectangular_array_write_read() { println!("{}", err); diff --git a/examples/sharded_array_write_read.rs b/examples/sharded_array_write_read.rs index f8b8a1e6..b12edd12 100644 --- a/examples/sharded_array_write_read.rs +++ b/examples/sharded_array_write_read.rs @@ -1,4 +1,3 @@ -#[cfg(all(feature = "ndarray", feature = "sharding"))] fn sharded_array_write_read() -> Result<(), Box> { use zarrs::{ array::{ @@ -154,11 +153,6 @@ fn sharded_array_write_read() -> Result<(), Box> { Ok(()) } -#[cfg(any(not(feature = "ndarray"), not(feature = "sharding")))] -fn sharded_array_write_read() -> Result<(), Box> { - panic!("the sharded_array_write_read example requires the ndarray and sharding feature") -} - fn main() { if let Err(err) = sharded_array_write_read() { println!("{}", err); diff --git a/examples/zip_array_write_read.rs b/examples/zip_array_write_read.rs index 9091143d..f89ac300 100644 --- a/examples/zip_array_write_read.rs +++ b/examples/zip_array_write_read.rs @@ -139,7 +139,6 @@ fn zip_dir( Result::Ok(()) } -#[cfg(feature = "ndarray")] fn zip_array_write_read() -> Result<(), Box> { use walkdir::WalkDir; use zarrs::{ @@ -179,11 +178,6 @@ fn zip_array_write_read() -> Result<(), Box> { Ok(()) } -#[cfg(not(feature = "ndarray"))] -fn zip_array_write_read() -> Result<(), Box> { - panic!("the array_write_read example requires the ndarray feature") -} - fn main() { if let Err(err) = zip_array_write_read() { println!("{}", err);