Skip to content

Commit

Permalink
WIP: add debug_assert instead of panic
Browse files Browse the repository at this point in the history
  • Loading branch information
grtlr committed Nov 21, 2024
1 parent f7b2cc6 commit b2a1f14
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 7 additions & 4 deletions crates/viewer/re_space_view_graph/src/layout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions crates/viewer/re_space_view_graph/src/ui/state.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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.
}
}
}

0 comments on commit b2a1f14

Please sign in to comment.