Skip to content

Commit

Permalink
Use required-features for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
LDeakin committed Dec 4, 2023
1 parent e8315a6 commit 39c92b6
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 42 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
28 changes: 28 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions examples/array_write_read.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[cfg(feature = "ndarray")]
fn array_write_read() -> Result<(), Box<dyn std::error::Error>> {
use rayon::prelude::{IntoParallelIterator, ParallelIterator};
use std::sync::Arc;
Expand Down Expand Up @@ -121,11 +120,6 @@ fn array_write_read() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}

#[cfg(not(feature = "ndarray"))]
fn array_write_read() -> Result<(), Box<dyn std::error::Error>> {
panic!("the array_write_read example requires the ndarray feature")
}

fn main() {
if let Err(err) = array_write_read() {
println!("{}", err);
Expand Down
6 changes: 0 additions & 6 deletions examples/async_array_write_read.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[cfg(feature = "ndarray")]
async fn async_array_write_read() -> Result<(), Box<dyn std::error::Error>> {
use futures::{stream::FuturesUnordered, StreamExt};
use std::sync::Arc;
Expand Down Expand Up @@ -140,11 +139,6 @@ async fn async_array_write_read() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}

#[cfg(not(feature = "ndarray"))]
async fn async_array_write_read() -> Result<(), Box<dyn std::error::Error>> {
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 {
Expand Down
6 changes: 0 additions & 6 deletions examples/async_http_array_read.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[cfg(all(feature = "ndarray", feature = "async"))]
async fn http_array_read() -> Result<(), Box<dyn std::error::Error>> {
use std::sync::Arc;
use zarrs::{
Expand Down Expand Up @@ -58,11 +57,6 @@ async fn http_array_read() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}

#[cfg(any(not(feature = "ndarray"), not(feature = "async")))]
async fn http_array_read() -> Result<(), Box<dyn std::error::Error>> {
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 {
Expand Down
6 changes: 0 additions & 6 deletions examples/http_array_read.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[cfg(feature = "ndarray")]
fn http_array_read() -> Result<(), Box<dyn std::error::Error>> {
use std::sync::Arc;
use zarrs::{
Expand Down Expand Up @@ -52,11 +51,6 @@ fn http_array_read() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}

#[cfg(not(feature = "ndarray"))]
fn http_array_read() -> Result<(), Box<dyn std::error::Error>> {
panic!("the http_array_read example requires the ndarray feature")
}

fn main() {
if let Err(err) = http_array_read() {
println!("{}", err);
Expand Down
6 changes: 0 additions & 6 deletions examples/rectangular_array_write_read.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[cfg(feature = "ndarray")]
fn rectangular_array_write_read() -> Result<(), Box<dyn std::error::Error>> {
use rayon::prelude::{IntoParallelIterator, ParallelIterator};
use zarrs::array::ChunkGrid;
Expand Down Expand Up @@ -123,11 +122,6 @@ fn rectangular_array_write_read() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}

#[cfg(not(feature = "ndarray"))]
fn rectangular_array_write_read() -> Result<(), Box<dyn std::error::Error>> {
panic!("the rectangular_array_write_read example requires the ndarray feature")
}

fn main() {
if let Err(err) = rectangular_array_write_read() {
println!("{}", err);
Expand Down
6 changes: 0 additions & 6 deletions examples/sharded_array_write_read.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[cfg(all(feature = "ndarray", feature = "sharding"))]
fn sharded_array_write_read() -> Result<(), Box<dyn std::error::Error>> {
use zarrs::{
array::{
Expand Down Expand Up @@ -154,11 +153,6 @@ fn sharded_array_write_read() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}

#[cfg(any(not(feature = "ndarray"), not(feature = "sharding")))]
fn sharded_array_write_read() -> Result<(), Box<dyn std::error::Error>> {
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);
Expand Down
6 changes: 0 additions & 6 deletions examples/zip_array_write_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ fn zip_dir(
Result::Ok(())
}

#[cfg(feature = "ndarray")]
fn zip_array_write_read() -> Result<(), Box<dyn std::error::Error>> {
use walkdir::WalkDir;
use zarrs::{
Expand Down Expand Up @@ -179,11 +178,6 @@ fn zip_array_write_read() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}

#[cfg(not(feature = "ndarray"))]
fn zip_array_write_read() -> Result<(), Box<dyn std::error::Error>> {
panic!("the array_write_read example requires the ndarray feature")
}

fn main() {
if let Err(err) = zip_array_write_read() {
println!("{}", err);
Expand Down

0 comments on commit 39c92b6

Please sign in to comment.