diff options
author | Fredrik Meringdal <fmeringdal@hotmail.com> | 2020-10-21 12:49:40 +0200 |
---|---|---|
committer | Fredrik Meringdal <fmeringdal@hotmail.com> | 2020-10-21 12:49:40 +0200 |
commit | 3dbab982cb2709639d0cb3961a60069b6b3b0dec (patch) | |
tree | 69d0961489c99aed81e8391af2d613729d47b632 | |
parent | 0f992d031ade1119e7e081e75caba93b25099b0b (diff) | |
download | rust_rrule-3dbab982cb2709639d0cb3961a60069b6b3b0dec.zip |
checkpoint
-rw-r--r-- | src/iter.rs | 8 | ||||
-rw-r--r-- | src/iter_set.rs | 4 | ||||
-rw-r--r-- | src/rrule.rs | 4 | ||||
-rw-r--r-- | src/rruleset.rs | 10 |
4 files changed, 13 insertions, 13 deletions
diff --git a/src/iter.rs b/src/iter.rs index c69eb3e..4b0d68a 100644 --- a/src/iter.rs +++ b/src/iter.rs @@ -1,5 +1,5 @@ use crate::datetime::*; -use crate::iter_set::TIterResult; +use crate::iter_set::IterResult; use crate::iterinfo::*; use crate::options::*; use crate::poslist::*; @@ -22,7 +22,7 @@ pub struct IterArgs { pub dt: DateTime<Tz>, } -pub struct IterResult { +pub struct RRuleIterRes { pub method: QueryMethodTypes, pub args: IterArgs, pub min_date: Option<DateTime<Tz>>, @@ -31,7 +31,7 @@ pub struct IterResult { pub total: usize, } -impl IterResult { +impl RRuleIterRes { pub fn new(method: QueryMethodTypes, args: IterArgs) -> Self { let (max_date, min_date) = match method { QueryMethodTypes::BETWEEN if args.inc => (Some(args.before), Some(args.after)), @@ -62,7 +62,7 @@ impl IterResult { } } -impl TIterResult for IterResult { +impl IterResult for RRuleIterRes { fn accept(&mut self, date: DateTime<Tz>) -> bool { self.total += 1; let too_early = self.min_date.is_some() && date < self.min_date.unwrap(); diff --git a/src/iter_set.rs b/src/iter_set.rs index dcff97f..077154b 100644 --- a/src/iter_set.rs +++ b/src/iter_set.rs @@ -9,12 +9,12 @@ use chrono::{DateTime, Duration, Utc}; use chrono_tz::*; use std::collections::HashMap; -pub trait TIterResult { +pub trait IterResult { fn accept(&mut self, date: DateTime<Tz>) -> bool; fn get_value(&self) -> Vec<DateTime<Tz>>; } -pub fn iter_v2<T: TIterResult>( +pub fn iter_v2<T: IterResult>( iter_result: &mut T, options: &mut ParsedOptions, ) -> Vec<DateTime<Tz>> { diff --git a/src/rrule.rs b/src/rrule.rs index ab13a9c..706c30a 100644 --- a/src/rrule.rs +++ b/src/rrule.rs @@ -29,7 +29,7 @@ impl RRule { after: UTC.ymd(2020, 1, 1).and_hms(0, 0, 0), dt: UTC.ymd(2020, 1, 1).and_hms(0, 0, 0), }; - let mut iter_res = IterResult::new(QueryMethodTypes::ALL, iter_args); + let mut iter_res = RRuleIterRes::new(QueryMethodTypes::ALL, iter_args); let res = iter_v2(&mut iter_res, &mut self.options); res @@ -47,7 +47,7 @@ impl RRule { after: after.clone(), dt: UTC.ymd(2020, 1, 1).and_hms(0, 0, 0), }; - let mut iter_res = IterResult::new(QueryMethodTypes::ALL, iter_args); + let mut iter_res = RRuleIterRes::new(QueryMethodTypes::ALL, iter_args); let res = iter_v2(&mut iter_res, &mut self.options); res diff --git a/src/rruleset.rs b/src/rruleset.rs index 30a2c72..0bd91e7 100644 --- a/src/rruleset.rs +++ b/src/rruleset.rs @@ -1,5 +1,5 @@ use crate::iter::*; -use crate::iter_set::{iter_v2, TIterResult}; +use crate::iter_set::{iter_v2, IterResult}; use crate::options::*; use crate::rrule::*; use chrono::prelude::*; @@ -17,7 +17,7 @@ struct RRuleSet { struct RRuleSetIter<'a> { exdate_hash: HashMap<i64, ()>, - iter_res: IterResult, + iter_res: RRuleIterRes, rrule_set: &'a mut RRuleSet, } @@ -29,7 +29,7 @@ impl<'a> RRuleSetIter<'a> { after: UTC.ymd(2020, 1, 1).and_hms(0, 0, 0), dt: UTC.ymd(2020, 1, 1).and_hms(0, 0, 0), }; - let iter_res = IterResult::new(QueryMethodTypes::ALL, iter_args); + let iter_res = RRuleIterRes::new(QueryMethodTypes::ALL, iter_args); Self { exdate_hash: HashMap::new(), @@ -106,7 +106,7 @@ impl<'a> RRuleSetIter<'a> { } } -impl<'a> TIterResult for RRuleSetIter<'a> { +impl<'a> IterResult for RRuleSetIter<'a> { fn accept(&mut self, date: DateTime<Tz>) -> bool { match &self.iter_res.method { QueryMethodTypes::BETWEEN => self.accept_1(date), @@ -211,7 +211,7 @@ mod test_iter_set { month: u32, day: u32, hour: u32, - minute: u32, + minute: u32, second: u32, ) -> DateTime<Tz> { UTC.ymd(year, month, day).and_hms(hour, minute, second) |