Add lifetime parameter and MarkedCells struct

Refactor App, GameStates, SkirmishState and BoardState to carry a
generic
lifetime `'a`. Introduce a new `MarkedCells` type that holds marking
state
and selected unit, replacing the previous `marking_cells` flag and raw
deque. Update related methods, keybindings, view implementations and
module exports to use the new structures.
This commit is contained in:
2026-05-06 21:39:53 +02:00
parent b66c1d8e25
commit cd1822d05e
11 changed files with 78 additions and 38 deletions
+5 -5
View File
@@ -10,16 +10,16 @@ use std::{
time::Duration,
};
pub struct App {
pub struct App<'a> {
pub exit: bool,
pub view: View,
pub window_area: Rect,
pub args: Cli,
pub states: Option<GameStates>,
pub states: Option<GameStates<'a>>,
pub audio_tx: Sender<AudioCmd>,
}
impl App {
impl<'a> App<'a> {
pub fn new(args: Cli, audio_tx: Sender<AudioCmd>) -> Self {
Self {
exit: false,
@@ -31,11 +31,11 @@ impl App {
}
}
pub fn states(&self) -> Option<&GameStates> {
pub fn states_ref(&self) -> Option<&GameStates<'a>> {
self.states.as_ref()
}
pub fn states_mut(&mut self) -> Option<&mut GameStates> {
pub fn states_mut(&mut self) -> Option<&mut GameStates<'a>> {
self.states.as_mut()
}