diff options
| author | Rubén Beltrán del Río <jj@r.bdr.sh> | 2026-01-17 11:22:22 +0100 |
|---|---|---|
| committer | Rubén Beltrán del Río <jj@r.bdr.sh> | 2026-01-17 12:24:45 +0100 |
| commit | 88d6bf80f5cdbbb90ead197bd41a67eb8c44e50e (patch) | |
| tree | 401549b24fe8a747ef6739389b1b38f33ef016bb /src/handlers | |
| parent | 17898fbabde35ab346c133114e78614e707c0eca (diff) | |
Make clippy stricter and fix
Diffstat (limited to 'src/handlers')
| -rw-r--r-- | src/handlers/export.rs | 28 | ||||
| -rw-r--r-- | src/handlers/view.rs | 6 |
2 files changed, 20 insertions, 14 deletions
diff --git a/src/handlers/export.rs b/src/handlers/export.rs index a0a4451..bf9dfc5 100644 --- a/src/handlers/export.rs +++ b/src/handlers/export.rs @@ -18,23 +18,27 @@ use std::path::PathBuf; use crate::AppModel; use crate::actions::ImageFormat; use crate::dialogs; -use crate::tr; use crate::stages::LocalizedStageType; +use crate::tr; use wmap_renderer::{render_to_png, render_to_svg}; /// Exports the map to an image file in the specified format. -pub fn export_to_file(model: &AppModel, path: PathBuf, format: ImageFormat) { +pub fn export_to_file(model: &AppModel, path: &PathBuf, format: ImageFormat) { let result: Result<(), String> = match format { - ImageFormat::Png => { - render_to_png(&model.map, &model.stage_type.to_localized(), &model.render_configuration) - .map_err(|e| e.to_string()) - .and_then(|data| std::fs::write(&path, data).map_err(|e| e.to_string())) - } - ImageFormat::Svg => { - render_to_svg(&model.map, &model.stage_type.to_localized(), &model.render_configuration) - .map_err(|e| e.to_string()) - .and_then(|data| std::fs::write(&path, data).map_err(|e| e.to_string())) - } + ImageFormat::Png => render_to_png( + &model.map, + &model.stage_type.to_localized(), + &model.render_configuration, + ) + .map_err(|e| e.to_string()) + .and_then(|data| std::fs::write(path, data).map_err(|e| e.to_string())), + ImageFormat::Svg => render_to_svg( + &model.map, + &model.stage_type.to_localized(), + &model.render_configuration, + ) + .map_err(|e| e.to_string()) + .and_then(|data| std::fs::write(path, data).map_err(|e| e.to_string())), }; if let Err(error) = result { diff --git a/src/handlers/view.rs b/src/handlers/view.rs index 58d44b2..660f7b9 100644 --- a/src/handlers/view.rs +++ b/src/handlers/view.rs @@ -27,8 +27,10 @@ pub fn change_orientation(model: &mut AppModel) { /// Updates the selected stage type from dropdown selection. pub fn stage_type_selected(model: &mut AppModel, index: usize) { - if index < model.available_stage_types.len() { - model.stage_type = model.available_stage_types[index].clone(); + if index < model.available_stage_types.len() + && let Some(stage_type) = model.available_stage_types.get(index) + { + model.stage_type = stage_type.clone(); model.update_image(); } } |