libimagentrytag: Refactor code with is_match!() macro
This commit is contained in:
parent
394b90f038
commit
e30d2480ab
3 changed files with 6 additions and 2 deletions
|
@ -16,3 +16,6 @@ path = "../libimagstore"
|
|||
[dependencies.libimagerror]
|
||||
path = "../libimagerror"
|
||||
|
||||
[dependencies.libimagutil]
|
||||
path = "../libimagutil"
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue