From 9a3064739471d7bdd48e2f928edc52b63583a135 Mon Sep 17 00:00:00 2001 From: candifloss Date: Wed, 26 Nov 2025 11:47:23 +0530 Subject: [PATCH] Minor refactor - Separate function to find Unit symbol --- widget/src/show_popup.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/widget/src/show_popup.rs b/widget/src/show_popup.rs index da7bba1..56d5658 100644 --- a/widget/src/show_popup.rs +++ b/widget/src/show_popup.rs @@ -4,6 +4,15 @@ use slint::SharedString; slint::include_modules!(); +fn unit_symbol(units: &str) -> char { + match units { + "metric" => 'C', + "imperial" => 'F', + "standard" => 'K', + _ => '?', + } +} + pub fn show_popup(resp: &WeatherResponse, cfg: &Config) -> Result<(), Box> { let ui = MainWindow::new()?; @@ -22,12 +31,7 @@ pub fn show_popup(resp: &WeatherResponse, cfg: &Config) -> Result<(), Box 'C', - "imperial" => 'F', - "standard" => 'K', - _ => '?', - }; + let unit_symbol = unit_symbol(cfg.query_params.units.as_str()); ui.set_city(SharedString::from(city)); ui.set_country(SharedString::from(country)); @@ -35,7 +39,7 @@ pub fn show_popup(resp: &WeatherResponse, cfg: &Config) -> Result<(), Box