Remove unused lifetimes from app structs

This commit is contained in:
2026-05-12 10:48:48 +02:00
parent 19f4417172
commit d87316e4fe
7 changed files with 22 additions and 21 deletions
+5 -5
View File
@@ -10,16 +10,16 @@ use std::{
time::Duration, time::Duration,
}; };
pub struct App<'a> { pub struct App {
pub exit: bool, pub exit: bool,
pub view: View, pub view: View,
pub window_area: Rect, pub window_area: Rect,
pub args: Cli, pub args: Cli,
pub states: Option<GameStates<'a>>, pub states: Option<GameStates>,
pub audio_tx: Sender<AudioCmd>, pub audio_tx: Sender<AudioCmd>,
} }
impl<'a> App<'a> { impl App {
pub fn new(args: Cli, audio_tx: Sender<AudioCmd>) -> Self { pub fn new(args: Cli, audio_tx: Sender<AudioCmd>) -> Self {
Self { Self {
exit: false, exit: false,
@@ -31,11 +31,11 @@ impl<'a> App<'a> {
} }
} }
pub fn states_ref(&self) -> Option<&GameStates<'a>> { pub fn states_ref(&self) -> Option<&GameStates> {
self.states.as_ref() self.states.as_ref()
} }
pub fn states_mut(&mut self) -> Option<&mut GameStates<'a>> { pub fn states_mut(&mut self) -> Option<&mut GameStates> {
self.states.as_mut() self.states.as_mut()
} }
+3 -3
View File
@@ -8,15 +8,15 @@ use crate::{
use ratatui::layout::Rect; use ratatui::layout::Rect;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub struct GameStates<'a> { pub struct GameStates {
pub main_menu: MainMenuState, pub main_menu: MainMenuState,
pub skirmish: SkirmishState<'a>, pub skirmish: SkirmishState,
pub perk_decks: PerkDecksState, pub perk_decks: PerkDecksState,
pub skills_config: SkillsConfigState, pub skills_config: SkillsConfigState,
pub settings: SettingsState, pub settings: SettingsState,
} }
impl GameStates<'_> { impl GameStates {
pub fn new(args: &Cli, area: &Rect) -> Self { pub fn new(args: &Cli, area: &Rect) -> Self {
Self { Self {
main_menu: MainMenuState { main_menu: MainMenuState {
+3 -3
View File
@@ -1,15 +1,15 @@
use crate::app::states::skirmish_states::BoardState; use crate::app::states::skirmish_states::BoardState;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub struct SkirmishState<'a> { pub struct SkirmishState {
pub id: usize, pub id: usize,
pub name: &'static str, pub name: &'static str,
pub board: BoardState<'a>, pub board: BoardState,
pub side_panel: bool, pub side_panel: bool,
pub turn_counter: u64, pub turn_counter: u64,
} }
impl SkirmishState<'_> { impl SkirmishState {
pub fn tick_update(&mut self) { pub fn tick_update(&mut self) {
// self.board.advance_turn(); // self.board.advance_turn();
+5 -4
View File
@@ -14,7 +14,7 @@ use ratatui::layout::Rect;
use std::collections::VecDeque; use std::collections::VecDeque;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub struct BoardState<'a> { pub struct BoardState {
cells_area: Rect, cells_area: Rect,
pub cell_width: usize, pub cell_width: usize,
pub cell_height: usize, pub cell_height: usize,
@@ -31,10 +31,10 @@ pub struct BoardState<'a> {
enemy_base_coords: (usize, usize), enemy_base_coords: (usize, usize),
// pub marking_cells: bool, // pub marking_cells: bool,
// marked_cells: VecDeque<(usize, usize)>, // marked_cells: VecDeque<(usize, usize)>,
pub marked_cells: MarkedCells<'a>, pub marked_cells: MarkedCells,
} }
impl BoardState<'_> { impl BoardState {
pub fn new( pub fn new(
area: &Rect, area: &Rect,
map_width: usize, map_width: usize,
@@ -106,7 +106,7 @@ impl BoardState<'_> {
cells.push(rows); cells.push(rows);
} }
let marked_cells: MarkedCells<'_> = MarkedCells::new(); let marked_cells: MarkedCells = MarkedCells::new();
Self { Self {
cells_area, cells_area,
@@ -204,6 +204,7 @@ impl BoardState<'_> {
let cell: &mut CellWidget = self.get_mut_cell(row, col); let cell: &mut CellWidget = self.get_mut_cell(row, col);
cell.set_marked(true); cell.set_marked(true);
self.marked_cells.selected_unit = cell.get_option_unit();
self.marked_cells.marked_cells.push_back((row, col)); self.marked_cells.marked_cells.push_back((row, col));
} }
@@ -2,18 +2,18 @@ use crate::app::states::skirmish_states::units::Units;
use std::collections::VecDeque; use std::collections::VecDeque;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub struct MarkedCells<'a> { pub struct MarkedCells {
pub marking_cells: bool, pub marking_cells: bool,
pub marked_cells: VecDeque<(usize, usize)>, pub marked_cells: VecDeque<(usize, usize)>,
pub selected_unit: &'a Option<Units>, pub selected_unit: Option<Units>,
} }
impl MarkedCells<'_> { impl MarkedCells {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
marking_cells: false, marking_cells: false,
marked_cells: VecDeque::new(), marked_cells: VecDeque::new(),
selected_unit: &None, selected_unit: None,
} }
} }
} }
+1 -1
View File
@@ -13,7 +13,7 @@ pub enum View {
SkillsConfig, SkillsConfig,
} }
impl Widget for &mut App<'_> { impl Widget for &mut App {
fn render(self, area: Rect, buf: &mut Buffer) fn render(self, area: Rect, buf: &mut Buffer)
where where
Self: Sized, Self: Sized,
+1 -1
View File
@@ -7,7 +7,7 @@ use ratatui::{
use std::rc::Rc; use std::rc::Rc;
pub struct BoardWidget<'a> { pub struct BoardWidget<'a> {
state: &'a BoardState<'a>, state: &'a BoardState,
} }
impl<'a> BoardWidget<'a> { impl<'a> BoardWidget<'a> {