summaryrefslogtreecommitdiffstats
path: root/src/matcher.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/matcher.rs')
-rw-r--r--src/matcher.rs27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/matcher.rs b/src/matcher.rs
index 2676201..965a08c 100644
--- a/src/matcher.rs
+++ b/src/matcher.rs
@@ -1,11 +1,12 @@
-
use chrono::Datelike;
+#[cfg(feature = "with-filters")]
+use filters::filter::*;
-use error::Error;
-use error::Result;
-use indicator::Day;
-use indicator::Month;
-use timetype::TimeType;
+use crate::error::Error;
+use crate::error::Result;
+use crate::indicator::Day;
+use crate::indicator::Month;
+use crate::timetype::TimeType;
/// A trait to extend indicator::* to be able to match them with a TimeType object
pub trait Matcher {
@@ -13,9 +14,8 @@ pub trait Matcher {
}
impl Matcher for Day {
-
fn matches(&self, tt: &TimeType) -> Result<bool> {
- let this : ::chrono::Weekday = self.clone().into();
+ let this: chrono::Weekday = self.clone().into();
tt.get_moment()
.map(|mom| this == mom.weekday())
.ok_or(Error::ArgumentErrorNotAMoment(tt.name()))
@@ -23,25 +23,20 @@ impl Matcher for Day {
}
impl Matcher for Month {
-
fn matches(&self, tt: &TimeType) -> Result<bool> {
- let this : u32 = self.clone().into();
+ let this: u32 = self.clone().into();
tt.get_moment()
.map(|mom| this == mom.month())
.ok_or(Error::ArgumentErrorNotAMoment(tt.name()))
}
-
}
#[cfg(feature = "with-filters")]
-use filters::filter::*;
-
-#[cfg(feature = "with-filters")]
impl<F> Matcher for F
- where F: Filter<TimeType>
+where
+ F: Filter<TimeType>,
{
fn matches(&self, tt: &TimeType) -> Result<bool> {
Ok(self.filter(tt))
}
}
-