From 5b21b9417506d71483c9e5315636df1ac77541ff Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sun, 16 Nov 2025 11:45:40 +0100 Subject: [PATCH] Remove some `.unwrap()` --- crates/egui/src/containers/panel.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/crates/egui/src/containers/panel.rs b/crates/egui/src/containers/panel.rs index da39a2fd3..b8914596a 100644 --- a/crates/egui/src/containers/panel.rs +++ b/crates/egui/src/containers/panel.rs @@ -447,17 +447,15 @@ impl Panel { ) -> Option> { let how_expanded = animate_expansion(ctx, self.id.with("animation"), is_expanded); - let animated_panel = self.get_animated_panel(ctx, is_expanded); + let animated_panel = self.get_animated_panel(ctx, is_expanded)?; - if animated_panel.is_none() { - None - } else if how_expanded < 1.0 { + if how_expanded < 1.0 { // Show a fake panel in this in-between animation state: - animated_panel.unwrap().show(ctx, |_ui| {}); + animated_panel.show(ctx, |_ui| {}); None } else { // Show the real panel: - Some(animated_panel.unwrap().show(ctx, add_contents)) + Some(animated_panel.show(ctx, add_contents)) } } @@ -472,17 +470,15 @@ impl Panel { let how_expanded = animate_expansion(ui.ctx(), self.id.with("animation"), is_expanded); // Get either the fake or the real panel to animate - let animated_panel = self.get_animated_panel(ui.ctx(), is_expanded); + let animated_panel = self.get_animated_panel(ui.ctx(), is_expanded)?; - if animated_panel.is_none() { - None - } else if how_expanded < 1.0 { + if how_expanded < 1.0 { // Show a fake panel in this in-between animation state: - animated_panel.unwrap().show_inside(ui, |_ui| {}); + animated_panel.show_inside(ui, |_ui| {}); None } else { // Show the real panel: - Some(animated_panel.unwrap().show_inside(ui, add_contents)) + Some(animated_panel.show_inside(ui, add_contents)) } }