diff options
author | Fredrik Meringdal <fredrikmeringdal@Fredriks-MacBook-Pro.local> | 2021-02-04 10:32:12 +0100 |
---|---|---|
committer | Fredrik Meringdal <fredrikmeringdal@Fredriks-MacBook-Pro.local> | 2021-02-04 10:32:12 +0100 |
commit | daf5d106580ef0112ef9e1b3094248959a2c17fc (patch) | |
tree | ff159ed5012dcf5bd2059888eb207e3e3c4b7c67 /src | |
parent | 002d83f26f11e45e25258b2843746cf1737be6ab (diff) | |
download | rust_rrule-daf5d106580ef0112ef9e1b3094248959a2c17fc.zip |
reanming
Diffstat (limited to 'src')
-rw-r--r-- | src/rrule_iter.rs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/rrule_iter.rs b/src/rrule_iter.rs index 421e8ab..375fe00 100644 --- a/src/rrule_iter.rs +++ b/src/rrule_iter.rs @@ -13,7 +13,8 @@ pub struct RRuleIter { pub counter_date: DateTime<Tz>, pub ii: IterInfo, pub timeset: Vec<Time>, - pub remain: VecDeque<DateTime<Tz>>, + // Buffer of datetimes not yet yielded + pub buffer: VecDeque<DateTime<Tz>>, pub finished: bool, } @@ -25,16 +26,16 @@ impl Iterator for RRuleIter { return None; } - if !self.remain.is_empty() { - return self.remain.pop_front(); + if !self.buffer.is_empty() { + return self.buffer.pop_front(); } generate(self); - if self.remain.is_empty() { + if self.buffer.is_empty() { self.finished = true; } - self.remain.pop_front() + self.buffer.pop_front() } } @@ -50,7 +51,7 @@ pub fn generate(iter: &mut RRuleIter) { return; } - while iter.remain.is_empty() { + while iter.buffer.is_empty() { let (dayset, start, end) = iter.ii.getdayset( &iter.ii.options.freq, iter.counter_date.year() as isize, @@ -84,7 +85,7 @@ pub fn generate(iter: &mut RRuleIter) { } if res >= options.dtstart { - iter.remain.push_back(res); + iter.buffer.push_back(res); if let Some(count) = iter.ii.options.count { if count > 0 { @@ -120,7 +121,7 @@ pub fn generate(iter: &mut RRuleIter) { return; } if res >= options.dtstart { - iter.remain.push_back(res); + iter.buffer.push_back(res); if let Some(count) = iter.ii.options.count { if count > 0 { @@ -183,7 +184,7 @@ impl IntoIterator for RRule { counter_date, ii, timeset, - remain: VecDeque::new(), + buffer: VecDeque::new(), finished: false, } } |