diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2018-01-12 16:32:18 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2018-01-13 01:14:03 +0100 |
commit | 18a6e9b64e454047f87930fb558ddaa23e3f6e29 (patch) | |
tree | cca4dad8cef2cda042d3735e1d98bd32a59d4bee /lib/entry | |
parent | 6c36c978954de0e61c21b8e9deb2d03b87141598 (diff) |
libimagentryfilter: Replace read with typed read
Diffstat (limited to 'lib/entry')
3 files changed, 9 insertions, 21 deletions
diff --git a/lib/entry/libimagentryfilter/src/builtin/header/version/eq.rs b/lib/entry/libimagentryfilter/src/builtin/header/version/eq.rs index 138d1da0..0a56c751 100644 --- a/lib/entry/libimagentryfilter/src/builtin/header/version/eq.rs +++ b/lib/entry/libimagentryfilter/src/builtin/header/version/eq.rs @@ -21,7 +21,7 @@ use semver::Version; use libimagstore::store::Entry; -use toml_query::read::TomlValueReadExt; +use toml_query::read::TomlValueReadTypeExt; use filters::filter::Filter; pub struct VersionEq { @@ -40,13 +40,9 @@ impl Filter<Entry> for VersionEq { fn filter(&self, e: &Entry) -> bool { e.get_header() - .read("imag.version") + .read_string("imag.version") .map(|val| { - val.map_or(false, |v| { - v.as_str() - .map(|s| Version::parse(s).map(|v| v == self.version).unwrap_or(false)) - .unwrap_or(false) - }) + val.map_or(false, |s| Version::parse(&s).map(|v| v == self.version).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 edc89145..c4afbded 100644 --- a/lib/entry/libimagentryfilter/src/builtin/header/version/gt.rs +++ b/lib/entry/libimagentryfilter/src/builtin/header/version/gt.rs @@ -21,7 +21,7 @@ use semver::Version; use libimagstore::store::Entry; -use toml_query::read::TomlValueReadExt; +use toml_query::read::TomlValueReadTypeExt; use filters::filter::Filter; pub struct VersionGt { @@ -40,13 +40,9 @@ impl Filter<Entry> for VersionGt { fn filter(&self, e: &Entry) -> bool { e.get_header() - .read("imag.version") + .read_string("imag.version") .map(|val| { - val.map_or(false, |v| { - v.as_str() - .map(|s| Version::parse(s).map(|v| v > self.version).unwrap_or(false)) - .unwrap_or(false) - }) + val.map_or(false, |s| Version::parse(&s).map(|v| v > self.version).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 846c7f62..38b5000b 100644 --- a/lib/entry/libimagentryfilter/src/builtin/header/version/lt.rs +++ b/lib/entry/libimagentryfilter/src/builtin/header/version/lt.rs @@ -21,7 +21,7 @@ use semver::Version; use libimagstore::store::Entry; -use toml_query::read::TomlValueReadExt; +use toml_query::read::TomlValueReadTypeExt; use filters::filter::Filter; pub struct VersionLt { @@ -40,13 +40,9 @@ impl Filter<Entry> for VersionLt { fn filter(&self, e: &Entry) -> bool { e.get_header() - .read("imag.version") + .read_string("imag.version") .map(|val| { - val.map_or(false, |v| { - v.as_str() - .map(|s| Version::parse(s).map(|v| v < self.version).unwrap_or(false)) - .unwrap_or(false) - }) + val.map_or(false, |s| Version::parse(&s).map(|v| v < self.version).unwrap_or(false)) }) .unwrap_or(false) } |