From 3d50d55aa60f48fd7774e1cbd4b8365239011ab1 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 13 Sep 2023 08:08:09 +0200 Subject: [PATCH] cargo format let-else statements --- crates/egui_demo_app/src/apps/image_viewer.rs | 12 +++++++++--- crates/egui_extras/src/loaders/image_loader.rs | 2 +- crates/egui_extras/src/loaders/svg_loader.rs | 4 +++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/crates/egui_demo_app/src/apps/image_viewer.rs b/crates/egui_demo_app/src/apps/image_viewer.rs index 8bae74f0fc9..f1929b9101d 100644 --- a/crates/egui_demo_app/src/apps/image_viewer.rs +++ b/crates/egui_demo_app/src/apps/image_viewer.rs @@ -143,7 +143,9 @@ impl eframe::App for ImageViewer { if !matches!(self.fit, ImageFit::Exact(_)) { self.fit = ImageFit::Exact(Vec2::splat(128.0)); } - let ImageFit::Exact(size) = &mut self.fit else { unreachable!() }; + let ImageFit::Exact(size) = &mut self.fit else { + unreachable!() + }; ui.add(Slider::new(&mut size.x, 0.0..=2048.0).text("width")); ui.add(Slider::new(&mut size.y, 0.0..=2048.0).text("height")); } @@ -151,7 +153,9 @@ impl eframe::App for ImageViewer { if !matches!(self.fit, ImageFit::Fraction(_)) { self.fit = ImageFit::Fraction(Vec2::splat(1.0)); } - let ImageFit::Fraction(fract) = &mut self.fit else { unreachable!() }; + let ImageFit::Fraction(fract) = &mut self.fit else { + unreachable!() + }; ui.add(Slider::new(&mut fract.x, 0.0..=1.0).text("width")); ui.add(Slider::new(&mut fract.y, 0.0..=1.0).text("height")); } @@ -159,7 +163,9 @@ impl eframe::App for ImageViewer { if !matches!(self.fit, ImageFit::Original(_)) { self.fit = ImageFit::Original(Some(1.0)); } - let ImageFit::Original(Some(scale)) = &mut self.fit else { unreachable!() }; + let ImageFit::Original(Some(scale)) = &mut self.fit else { + unreachable!() + }; ui.add(Slider::new(scale, 0.1..=4.0).text("scale")); } } diff --git a/crates/egui_extras/src/loaders/image_loader.rs b/crates/egui_extras/src/loaders/image_loader.rs index 989efc63553..46098332d38 100644 --- a/crates/egui_extras/src/loaders/image_loader.rs +++ b/crates/egui_extras/src/loaders/image_loader.rs @@ -20,7 +20,7 @@ impl ImageCrateLoader { fn is_supported_uri(uri: &str) -> bool { let Some(ext) = Path::new(uri).extension().and_then(|ext| ext.to_str()) else { // `true` because if there's no extension, assume that we support it - return true + return true; }; ext != "svg" diff --git a/crates/egui_extras/src/loaders/svg_loader.rs b/crates/egui_extras/src/loaders/svg_loader.rs index ea98184f4f3..cb4263c719c 100644 --- a/crates/egui_extras/src/loaders/svg_loader.rs +++ b/crates/egui_extras/src/loaders/svg_loader.rs @@ -18,7 +18,9 @@ impl SvgLoader { } fn is_supported(uri: &str) -> bool { - let Some(ext) = Path::new(uri).extension().and_then(|ext| ext.to_str()) else { return false }; + let Some(ext) = Path::new(uri).extension().and_then(|ext| ext.to_str()) else { + return false; + }; ext == "svg" }