diff options
author | Ruben Pollan | 2018-08-28 20:33:43 +0200 |
---|---|---|
committer | Ruben Pollan | 2018-08-28 20:33:43 +0200 |
commit | 7e7dfc3d76b810f22f68f4e5334c9d89dd7d85cc (patch) | |
tree | af5832baf63c90c0a74c0b96a6fef776323096ca /src/periodic.rs | |
parent | d7fffd15cb148bab2fa9a9e58d3f323231aac5e3 (diff) |
Let's use Option the rustic way
Diffstat (limited to '')
-rw-r--r-- | src/periodic.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/periodic.rs b/src/periodic.rs index b4bf7bf..0c52a9b 100644 --- a/src/periodic.rs +++ b/src/periodic.rs @@ -12,8 +12,8 @@ pub struct Periodic { pub event: Event, pub freq: Freq, pub interval: i64, - pub count: i64, - pub until: Date, + pub count: Option<i64>, + pub until: Option<Date>, } #[derive(Debug)] @@ -33,8 +33,8 @@ impl Periodic { event: Event::new(), freq: Freq::Secondly, interval: 1, - until: Date::empty(), - count: 0, + count: None, + until: None, } } @@ -42,8 +42,8 @@ impl Periodic { match param { "FREQ" => self.freq = value.parse()?, "INTERVAL" => self.interval = value.parse()?, - "COUNT" => self.count = value.parse()?, - "UNTIL" => self.until = Date::parse(&value, "")?, + "COUNT" => self.count = Some(value.parse()?), + "UNTIL" => self.until = Some(Date::parse(&value, "")?), _ => (), } Ok(()) @@ -55,8 +55,8 @@ impl Periodic { let mut events = Vec::new(); let mut count = 0; while start <= *last { - if (!self.until.is_empty() && start <= self.until) || - (count != 0 && count >= self.count) + if (self.until.is_some() && start <= self.until.unwrap()) || + (self.count.is_some() && count >= self.count.unwrap()) { break; } |