diff --git a/libimagentrylink/Cargo.toml b/libimagentrylink/Cargo.toml index f14869be..e4aeb4a6 100644 --- a/libimagentrylink/Cargo.toml +++ b/libimagentrylink/Cargo.toml @@ -17,3 +17,6 @@ path = "../libimagstore" [dependencies.libimagerror] path = "../libimagerror" +[dependencies.libimagutil] +path = "../libimagutil" + diff --git a/libimagentrylink/src/internal.rs b/libimagentrylink/src/internal.rs index 16186ddb..0c6b977b 100644 --- a/libimagentrylink/src/internal.rs +++ b/libimagentrylink/src/internal.rs @@ -160,7 +160,7 @@ fn process_rw_result(links: StoreResult>) -> Result> { } }; - if !links.iter().all(|l| match *l { Value::String(_) => true, _ => false }) { + if !links.iter().all(|l| is_match!(*l, Value::String(_))) { debug!("At least one of the Values which were expected in the Array of links is a non-String!"); debug!("Generating LinkError"); return Err(LinkError::new(LinkErrorKind::ExistingLinkTypeWrong, None)); diff --git a/libimagentrylink/src/lib.rs b/libimagentrylink/src/lib.rs index e04b6bf4..4f3b6ee7 100644 --- a/libimagentrylink/src/lib.rs +++ b/libimagentrylink/src/lib.rs @@ -21,6 +21,7 @@ extern crate crypto; #[macro_use] extern crate libimagstore; #[macro_use] extern crate libimagerror; +#[macro_use] extern crate libimagutil; module_entry_path_mod!("links", "0.1.0"); diff --git a/libimagentrytag/Cargo.toml b/libimagentrytag/Cargo.toml index 2a4e1ed2..64d62192 100644 --- a/libimagentrytag/Cargo.toml +++ b/libimagentrytag/Cargo.toml @@ -16,3 +16,6 @@ path = "../libimagstore" [dependencies.libimagerror] path = "../libimagerror" +[dependencies.libimagutil] +path = "../libimagutil" + diff --git a/libimagentrytag/src/lib.rs b/libimagentrytag/src/lib.rs index 232de3b3..87e4fe87 100644 --- a/libimagentrytag/src/lib.rs +++ b/libimagentrytag/src/lib.rs @@ -20,6 +20,7 @@ extern crate toml; extern crate libimagstore; #[macro_use] extern crate libimagerror; +#[macro_use] extern crate libimagutil; pub mod error; pub mod exec; diff --git a/libimagentrytag/src/tagable.rs b/libimagentrytag/src/tagable.rs index 6206a53e..44143d98 100644 --- a/libimagentrytag/src/tagable.rs +++ b/libimagentrytag/src/tagable.rs @@ -37,7 +37,7 @@ impl Tagable for EntryHeader { match tags { Some(Value::Array(tags)) => { - if !tags.iter().all(|t| match *t { Value::String(_) => true, _ => false }) { + if !tags.iter().all(|t| is_match!(*t, Value::String(_))) { return Err(TagError::new(TagErrorKind::TagTypeError, None)); } if tags.iter().any(|t| match *t { @@ -110,7 +110,7 @@ impl Tagable for EntryHeader { } let tags = tags.unwrap(); - if !tags.iter().all(|t| match *t { Value::String(_) => true, _ => false }) { + if !tags.iter().all(|t| is_match!(*t, Value::String(_))) { return Err(TagError::new(TagErrorKind::TagTypeError, None)); } diff --git a/libimagstore/Cargo.toml b/libimagstore/Cargo.toml index 25001ed4..c35004c0 100644 --- a/libimagstore/Cargo.toml +++ b/libimagstore/Cargo.toml @@ -18,6 +18,9 @@ walkdir = "0.1.5" [dependencies.libimagerror] path = "../libimagerror" +[dependencies.libimagutil] +path = "../libimagutil" + [dev-dependencies] tempdir = "0.3.4" env_logger = "0.3" diff --git a/libimagstore/src/configuration.rs b/libimagstore/src/configuration.rs index 6004a3d8..33e0a49e 100644 --- a/libimagstore/src/configuration.rs +++ b/libimagstore/src/configuration.rs @@ -128,15 +128,13 @@ pub fn config_is_valid(config: &Option) -> bool { // The section "hooks" has maps which have a key "aspect" which has a value of type // String - check_all_inner_maps_have_key_with(t, "hooks", "aspect", |asp| { - match *asp { Value::String(_) => true, _ => false } - }) && + check_all_inner_maps_have_key_with(t, "hooks", "aspect", + |asp| is_match!(asp, &Value::String(_))) && // The section "aspects" has maps which have a key "parllel" which has a value of type // Boolean - check_all_inner_maps_have_key_with(t, "aspects", "parallel", |asp| { - match *asp { Value::Boolean(_) => true, _ => false, } - }) + check_all_inner_maps_have_key_with(t, "aspects", "parallel", + |asp| is_match!(asp, &Value::Boolean(_))) } _ => { write!(stderr(), "Store config is no table").ok(); diff --git a/libimagstore/src/hook/aspect.rs b/libimagstore/src/hook/aspect.rs index f3d914e4..29d8c375 100644 --- a/libimagstore/src/hook/aspect.rs +++ b/libimagstore/src/hook/aspect.rs @@ -41,7 +41,7 @@ impl StoreIdAccessor for Aspect { use crossbeam; let accessors : Vec = self.hooks.iter().map(|h| h.accessor()).collect(); - if !accessors.iter().all(|a| match *a { HDA::StoreIdAccess(_) => true, _ => false }) { + if !accessors.iter().all(|a| is_match!(*a, HDA::StoreIdAccess(_))) { return Err(HE::new(HEK::AccessTypeViolation, None)); } @@ -76,11 +76,7 @@ impl MutableHookDataAccessor for Aspect { let accessors : Vec = self.hooks.iter().map(|h| h.accessor()).collect(); fn is_file_accessor(a: &HDA) -> bool { - match *a { - HDA::MutableAccess(_) | - HDA::NonMutableAccess(_) => true, - _ => false, - } + is_match!(*a, HDA::MutableAccess(_) | HDA::NonMutableAccess(_)) } if !accessors.iter().all(|a| is_file_accessor(a)) { @@ -108,7 +104,7 @@ impl NonMutableHookDataAccessor for Aspect { use crossbeam; let accessors : Vec = self.hooks.iter().map(|h| h.accessor()).collect(); - if !accessors.iter().all(|a| match *a { HDA::NonMutableAccess(_) => true, _ => false }) { + if !accessors.iter().all(|a| is_match!(*a, HDA::NonMutableAccess(_))) { return Err(HE::new(HEK::AccessTypeViolation, None)); } diff --git a/libimagstore/src/lib.rs b/libimagstore/src/lib.rs index 89657283..1be684b3 100644 --- a/libimagstore/src/lib.rs +++ b/libimagstore/src/lib.rs @@ -25,6 +25,7 @@ extern crate crossbeam; extern crate walkdir; #[macro_use] extern crate libimagerror; +#[macro_use] extern crate libimagutil; pub mod storeid; pub mod error;