Skip to content

Commit

Permalink
cargo format let-else statements
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Sep 13, 2023
1 parent d5369de commit 3d50d55
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
12 changes: 9 additions & 3 deletions crates/egui_demo_app/src/apps/image_viewer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,23 +143,29 @@ 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"));
}
ChosenFit::Fraction => {
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"));
}
ChosenFit::OriginalSize => {
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"));
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_extras/src/loaders/image_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion crates/egui_extras/src/loaders/svg_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit 3d50d55

Please sign in to comment.