From 3c7e5e1d4c0685a2c95681146d303bec3389ddc5 Mon Sep 17 00:00:00 2001 From: calcu1on Date: Thu, 3 Apr 2025 22:57:13 -0400 Subject: [PATCH] Even better handling of the periods. --- src/weather.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/weather.rs b/src/weather.rs index a2b442b..6c539ad 100644 --- a/src/weather.rs +++ b/src/weather.rs @@ -53,18 +53,12 @@ pub fn get_full_forecast(location: WeatherOfficeLocation) -> Vec .expect("Unable to get data") .text().unwrap().to_string(); let json: ForecastWrapper = serde_json::from_str(&forecast).expect("JSON was not well-formatted"); - let weather_periods: Vec = json.properties.periods.into_iter().collect(); - let icon_forecasts = enhance_forecasts(weather_periods); - icon_forecasts -} - -pub fn enhance_forecasts(mut periods: Vec) -> Vec { - for period in periods.iter_mut() { + let mut weather_periods: Vec = json.properties.periods.into_iter().collect(); + for period in weather_periods.iter_mut() { let icon = detect_icon(&period.short_forecast).unwrap(); - let icon_forecast = format!("{} {}", icon, &period.detailed_forecast); - period.detailed_forecast = icon_forecast; + period.detailed_forecast = format!("{} {}", icon, &period.detailed_forecast); } - periods + weather_periods } pub fn detect_icon(short_forecast: &String) -> Option {