summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNora <nora.widdecke@tu-bs.de>2019-03-27 15:15:34 +0100
committerNora <nora.widdecke@tu-bs.de>2019-03-27 15:15:34 +0100
commitcb0440387b5ef3ef3c2c65e72e60c425bab667ac (patch)
tree9eb0e14ab993d49b21d3f03b692f276b190cdae1
parent4ffbfd68d07d0626e3d78224d92f780abbfef30f (diff)
icalvevent: make get_duration_internal a little more elegant
-rw-r--r--src/icalwrap/icalvevent.rs20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/icalwrap/icalvevent.rs b/src/icalwrap/icalvevent.rs
index 12b1ab9..2b48835 100644
--- a/src/icalwrap/icalvevent.rs
+++ b/src/icalwrap/icalvevent.rs
@@ -64,16 +64,13 @@ impl IcalVEvent {
}
pub fn get_duration(&self) -> Option<IcalDuration> {
- match self.get_duration_internal() {
- Some(duration) => Some(duration),
- None => {
- if self.get_dtstart()?.is_date() {
- Some(IcalDuration::from_seconds(24 * 60 * 60))
- } else {
- Some(IcalDuration::from_seconds(0))
- }
+ self.get_duration_internal().or_else(|| {
+ if self.get_dtstart()?.is_date() {
+ Some(IcalDuration::from_seconds(24 * 60 * 60))
+ } else {
+ Some(IcalDuration::from_seconds(0))
}
- }
+ })
}
pub fn get_dtstart(&self) -> Option<IcalTime> {
@@ -317,10 +314,7 @@ mod tests {
let cal = IcalVCalendar::from_str(testdata::TEST_DTSTART_ONLY_DATETIME, None).unwrap();
let event = cal.get_principal_event();
- assert_eq!(
- Some(IcalDuration::from_seconds(0)),
- event.get_duration()
- );
+ assert_eq!(Some(IcalDuration::from_seconds(0)), event.get_duration());
}
#[test]