libimagentrytag: Refactor code with is_match!() macro

This commit is contained in:
Matthias Beyer 2016-05-23 21:42:49 +02:00
parent 394b90f038
commit e30d2480ab
3 changed files with 6 additions and 2 deletions

View file

@ -16,3 +16,6 @@ path = "../libimagstore"
[dependencies.libimagerror]
path = "../libimagerror"
[dependencies.libimagutil]
path = "../libimagutil"

View file

@ -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;

View file

@ -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));
}