From b2a1f14bd0570a0b3abda45ce7a4f6d2d74fa192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Thu, 21 Nov 2024 09:44:30 +0100 Subject: [PATCH] WIP: add `debug_assert` instead of panic --- crates/viewer/re_space_view_graph/src/layout/mod.rs | 11 +++++++---- crates/viewer/re_space_view_graph/src/ui/state.rs | 3 +-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/viewer/re_space_view_graph/src/layout/mod.rs b/crates/viewer/re_space_view_graph/src/layout/mod.rs index b3f275d9c0c5..e9161136767c 100644 --- a/crates/viewer/re_space_view_graph/src/layout/mod.rs +++ b/crates/viewer/re_space_view_graph/src/layout/mod.rs @@ -22,10 +22,13 @@ impl Layout { } pub fn update(&mut self, node: &NodeIndex, rect: Rect) { - *self - .extents - .get_mut(node) - .expect("node should exist in layout") = rect; + debug_assert!( + self.extents.contains_key(node), + "node should exist in the layout" + ); + if let Some(extent) = self.extents.get_mut(node) { + *extent = rect; + } } /// Returns `true` if any node has a zero size. diff --git a/crates/viewer/re_space_view_graph/src/ui/state.rs b/crates/viewer/re_space_view_graph/src/ui/state.rs index ff23e75773e0..ef597b554162 100644 --- a/crates/viewer/re_space_view_graph/src/ui/state.rs +++ b/crates/viewer/re_space_view_graph/src/ui/state.rs @@ -1,7 +1,6 @@ use egui::Rect; use re_chunk::{TimeInt, Timeline}; use re_format::format_f32; -use re_log::external::log; use re_types::blueprint::components::VisualBounds2D; use re_ui::UiExt; use re_viewer_context::SpaceViewState; @@ -179,7 +178,7 @@ impl LayoutState { match self { Self::Finished { layout, .. } | Self::InProgress { layout, .. } => layout, - _ => unreachable!(), // We just set the state to `Self::Current` above. + Self::None => unreachable!(), // We just set the state to `Self::Current` above. } } }