refactor: make active_view and axis_of infallible
Both functions previously returned Option despite their invariants guaranteeing a value: active_view always names an existing view (maintained by new/switch_view/delete_view), and axis_of only returns None for categories never registered with the view (a programming error). Callers no longer need to handle the impossible None case, eliminating ~15 match/if-let Option guards across app.rs, dispatch.rs, grid.rs, tile_bar.rs, and category_panel.rs. Also adds Model::evaluate_f64 (returns 0.0 for empty cells) and collapses the double match-on-axis pattern in tile_bar/category_panel into a single axis_display(Axis) helper. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@ -104,24 +104,18 @@ pub fn dispatch(model: &mut Model, cmd: &Command) -> CommandResult {
|
||||
}
|
||||
|
||||
Command::SetAxis { category, axis } => {
|
||||
match model.active_view_mut() {
|
||||
Some(view) => { view.set_axis(category, *axis); CommandResult::ok() }
|
||||
None => CommandResult::err("No active view"),
|
||||
}
|
||||
model.active_view_mut().set_axis(category, *axis);
|
||||
CommandResult::ok()
|
||||
}
|
||||
|
||||
Command::SetPageSelection { category, item } => {
|
||||
match model.active_view_mut() {
|
||||
Some(view) => { view.set_page_selection(category, item); CommandResult::ok() }
|
||||
None => CommandResult::err("No active view"),
|
||||
}
|
||||
model.active_view_mut().set_page_selection(category, item);
|
||||
CommandResult::ok()
|
||||
}
|
||||
|
||||
Command::ToggleGroup { category, group } => {
|
||||
match model.active_view_mut() {
|
||||
Some(view) => { view.toggle_group_collapse(category, group); CommandResult::ok() }
|
||||
None => CommandResult::err("No active view"),
|
||||
}
|
||||
model.active_view_mut().toggle_group_collapse(category, group);
|
||||
CommandResult::ok()
|
||||
}
|
||||
|
||||
Command::Save { path } => {
|
||||
|
||||
Reference in New Issue
Block a user