diff --git a/lib/entry/libimagentryfilter/src/builtin/header/field_predicate.rs b/lib/entry/libimagentryfilter/src/builtin/header/field_predicate.rs index a167f762..8c98aad8 100644 --- a/lib/entry/libimagentryfilter/src/builtin/header/field_predicate.rs +++ b/lib/entry/libimagentryfilter/src/builtin/header/field_predicate.rs @@ -52,12 +52,7 @@ impl Filter for FieldPredicate

{ fn filter(&self, e: &Entry) -> bool { e.get_header() .read(&self.header_field_path[..]) - .map(|val| { - match val { - None => false, - Some(v) => (*self.predicate).evaluate(v), - } - }) + .map(|val| val.map(|v| (*self.predicate).evaluate(v)).unwrap_or(false)) .unwrap_or(false) } diff --git a/lib/entry/libimagentryfilter/src/builtin/header/version/eq.rs b/lib/entry/libimagentryfilter/src/builtin/header/version/eq.rs index 5ba9f306..138d1da0 100644 --- a/lib/entry/libimagentryfilter/src/builtin/header/version/eq.rs +++ b/lib/entry/libimagentryfilter/src/builtin/header/version/eq.rs @@ -18,7 +18,6 @@ // use semver::Version; -use toml::Value; use libimagstore::store::Entry; @@ -44,15 +43,9 @@ impl Filter for VersionEq { .read("imag.version") .map(|val| { val.map_or(false, |v| { - match *v { - Value::String(ref s) => { - match Version::parse(&s[..]) { - Ok(v) => v == self.version, - _ => false - } - }, - _ => false, - } + v.as_str() + .map(|s| Version::parse(s).map(|v| v == self.version).unwrap_or(false)) + .unwrap_or(false) }) }) .unwrap_or(false) diff --git a/lib/entry/libimagentryfilter/src/builtin/header/version/gt.rs b/lib/entry/libimagentryfilter/src/builtin/header/version/gt.rs index edd0580f..edc89145 100644 --- a/lib/entry/libimagentryfilter/src/builtin/header/version/gt.rs +++ b/lib/entry/libimagentryfilter/src/builtin/header/version/gt.rs @@ -18,7 +18,6 @@ // use semver::Version; -use toml::Value; use libimagstore::store::Entry; @@ -44,15 +43,9 @@ impl Filter for VersionGt { .read("imag.version") .map(|val| { val.map_or(false, |v| { - match *v { - Value::String(ref s) => { - match Version::parse(&s[..]) { - Ok(v) => v > self.version, - _ => false - } - }, - _ => false, - } + v.as_str() + .map(|s| Version::parse(s).map(|v| v > self.version).unwrap_or(false)) + .unwrap_or(false) }) }) .unwrap_or(false) diff --git a/lib/entry/libimagentryfilter/src/builtin/header/version/lt.rs b/lib/entry/libimagentryfilter/src/builtin/header/version/lt.rs index 629be9ae..846c7f62 100644 --- a/lib/entry/libimagentryfilter/src/builtin/header/version/lt.rs +++ b/lib/entry/libimagentryfilter/src/builtin/header/version/lt.rs @@ -18,7 +18,6 @@ // use semver::Version; -use toml::Value; use libimagstore::store::Entry; @@ -44,15 +43,9 @@ impl Filter for VersionLt { .read("imag.version") .map(|val| { val.map_or(false, |v| { - match *v { - Value::String(ref s) => { - match Version::parse(&s[..]) { - Ok(v) => v < self.version, - _ => false - } - }, - _ => false, - } + v.as_str() + .map(|s| Version::parse(s).map(|v| v < self.version).unwrap_or(false)) + .unwrap_or(false) }) }) .unwrap_or(false)