summaryrefslogtreecommitdiffstats
path: root/src/indicator.rs
diff options
context:
space:
mode:
authorPro <twisted.fall@gmail.com>2024-02-09 21:53:42 +0100
committerPro <twisted.fall@gmail.com>2024-02-09 21:53:42 +0100
commit1ba7fa469d04530444eb0bc6d7c9ee2fd41457f6 (patch)
treecc732a509acad26a5f484246eefaddddde776154 /src/indicator.rs
parent3fe862d63b4be68f62f8de737c5322ce22ea8dd9 (diff)
Bump edition to 2021 and introduce rustfmt
Diffstat (limited to 'src/indicator.rs')
-rw-r--r--src/indicator.rs56
1 files changed, 27 insertions, 29 deletions
diff --git a/src/indicator.rs b/src/indicator.rs
index 39bd371..a89b0f0 100644
--- a/src/indicator.rs
+++ b/src/indicator.rs
@@ -1,14 +1,12 @@
#[cfg(feature = "with-filters")]
+use chrono::Datelike;
+#[cfg(feature = "with-filters")]
use filters::filter::Filter;
-
#[cfg(feature = "with-filters")]
use filters::filter::IntoFilter;
#[cfg(feature = "with-filters")]
-use timetype::TimeType;
-
-#[cfg(feature = "with-filters")]
-use chrono::Datelike;
+use crate::timetype::TimeType;
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug)]
pub enum Day {
@@ -24,13 +22,13 @@ pub enum Day {
impl From<Day> for chrono::Weekday {
fn from(val: Day) -> Self {
match val {
- Day::Monday => chrono::Weekday::Mon,
- Day::Tuesday => chrono::Weekday::Tue,
+ Day::Monday => chrono::Weekday::Mon,
+ Day::Tuesday => chrono::Weekday::Tue,
Day::Wednesday => chrono::Weekday::Wed,
- Day::Thursday => chrono::Weekday::Thu,
- Day::Friday => chrono::Weekday::Fri,
- Day::Saturday => chrono::Weekday::Sat,
- Day::Sunday => chrono::Weekday::Sun,
+ Day::Thursday => chrono::Weekday::Thu,
+ Day::Friday => chrono::Weekday::Fri,
+ Day::Saturday => chrono::Weekday::Sat,
+ Day::Sunday => chrono::Weekday::Sun,
}
}
}
@@ -54,18 +52,18 @@ pub enum Month {
impl From<Month> for u32 {
fn from(val: Month) -> Self {
match val {
- Month::January => 1,
- Month::February => 2,
- Month::March => 3,
- Month::April => 4,
- Month::May => 5,
- Month::June => 6,
- Month::July => 7,
- Month::August => 8,
- Month::September => 9,
- Month::October => 10,
- Month::November => 11,
- Month::December => 12,
+ Month::January => 1,
+ Month::February => 2,
+ Month::March => 3,
+ Month::April => 4,
+ Month::May => 5,
+ Month::June => 6,
+ Month::July => 7,
+ Month::August => 8,
+ Month::September => 9,
+ Month::October => 10,
+ Month::November => 11,
+ Month::December => 12,
}
}
}
@@ -76,7 +74,9 @@ pub struct DayFilter(Day);
#[cfg(feature = "with-filters")]
impl Filter<TimeType> for DayFilter {
fn filter(&self, tt: &TimeType) -> bool {
- tt.get_moment().map(|mom| mom.weekday() == self.0.clone().into()).unwrap_or(false)
+ tt.get_moment()
+ .map(|mom| mom.weekday() == self.0.clone().into())
+ .unwrap_or(false)
}
}
@@ -87,17 +87,17 @@ impl IntoFilter<TimeType> for Day {
fn into_filter(self) -> Self::IntoFilt {
DayFilter(self)
}
-
}
-
#[cfg(feature = "with-filters")]
pub struct MonthFilter(Month);
#[cfg(feature = "with-filters")]
impl Filter<TimeType> for MonthFilter {
fn filter(&self, tt: &TimeType) -> bool {
- tt.get_moment().map(|mom| mom.month() == self.0.clone().into()).unwrap_or(false)
+ tt.get_moment()
+ .map(|mom| mom.month() == self.0.clone().into())
+ .unwrap_or(false)
}
}
@@ -108,6 +108,4 @@ impl IntoFilter<TimeType> for Month {
fn into_filter(self) -> Self::IntoFilt {
MonthFilter(self)
}
-
}
-