From 19f172f13b6651f8725784a7b1571be784b80df8 Mon Sep 17 00:00:00 2001 From: RanXom Date: Fri, 12 Jun 2026 23:02:59 +0530 Subject: shorten if let in state using chained if let --- src/pomo/state.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/pomo/state.rs b/src/pomo/state.rs index 46c2dc1..2a59042 100644 --- a/src/pomo/state.rs +++ b/src/pomo/state.rs @@ -43,20 +43,20 @@ impl Default for Theme { if let Some(base_dirs) = BaseDirs::new() { let path = base_dirs.home_dir().join(".config/noctalia/colors.json"); - if let Ok(content) = fs::read_to_string(&path) { - if let Ok(colors) = serde_json::from_str::(&content) { - if let Some(c) = parse_hex_color(&colors.m_primary) { - theme.primary = c; - } - if let Some(c) = parse_hex_color(&colors.m_on_surface_variant) { - theme.overlay0 = c; - } - if let Some(c) = parse_hex_color(&colors.m_surface_variant) { - theme.surface0 = c; - } - if let Some(c) = parse_hex_color(&colors.m_on_surface) { - theme.text = c; - } + if let Ok(content) = fs::read_to_string(&path) + && let Ok(colors) = serde_json::from_str::(&content) + { + if let Some(c) = parse_hex_color(&colors.m_primary) { + theme.primary = c; + } + if let Some(c) = parse_hex_color(&colors.m_on_surface_variant) { + theme.overlay0 = c; + } + if let Some(c) = parse_hex_color(&colors.m_surface_variant) { + theme.surface0 = c; + } + if let Some(c) = parse_hex_color(&colors.m_on_surface) { + theme.text = c; } } } @@ -180,7 +180,7 @@ impl Pomo { match self.mode { SessionMode::Work => { self.break_count += 1; - if self.break_count % 3 == 0 { + if self.break_count.is_multiple_of(3) { self.mode = SessionMode::LongBreak; self.time_remaining = self.long_break_time; self.total_duration = self.long_break_time; -- cgit v1.2.3