summaryrefslogtreecommitdiffstats
path: root/src/matcher.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2024-02-10 08:08:27 +0100
committerGitHub <noreply@github.com>2024-02-10 08:08:27 +0100
commitcdbfa55a2bd38a250bae5eb3bbfe89bd3190cc37 (patch)
treecc732a509acad26a5f484246eefaddddde776154 /src/matcher.rs
parent736933d81e4c207fbe10e4d1477c2e56968c99be (diff)
parent1ba7fa469d04530444eb0bc6d7c9ee2fd41457f6 (diff)
Merge pull request #5 from twistedfall/master
Bump dependencies and do some cleanup
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))
}
}
-