From 2f5bb538b2be531b9e5632a5eb9a104181bac022 Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Mon, 28 Oct 2024 02:17:38 +0100 Subject: [PATCH] Remove unwrap when getting active schedule --- src/models/relay.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/models/relay.rs b/src/models/relay.rs index 5cb97d1..0b3e16c 100644 --- a/src/models/relay.rs +++ b/src/models/relay.rs @@ -113,7 +113,9 @@ impl Relay { } } - self.active_schedule = Some(self.schedules.get(weekday as usize).unwrap().clone()) + if let Some(schedule) = self.schedules.get(weekday as usize) { + self.active_schedule = Some(schedule.clone()); + } } pub fn apply_state(&mut self, state: &RelayState) {