Add rustfmt configuration and reformat code

- Document new Rust formatting standards in AGENTS, CODE_MAP, and
  PROGRESS.
- Add rustfmt.toml with style 2024, 2‑space indents, 100‑char width, LF
  endings.
- Apply consistent 2‑space indentation and ordering across source files.
- Minor clean‑up of imports and whitespace to match the new style.
This commit is contained in:
GarandPLG committed 2026-10-19 12:21:20 +02:00
1 parent 9e09aaf75e
commit c4313b4117
60 files changed
+3632 -3610

No files matched your search

+104 -101
View File
@@ -1,147 +1,150 @@
use crate::app::states::skirmish_states::{
Players,
tasks::Tasks,
units::{MinerUnit, Unit},
Players,
tasks::Tasks,
units::{MinerUnit, Unit},
};
use ratatui::text::Line;
use std::collections::VecDeque;
#[derive(Debug, Clone, PartialEq)]
pub enum Units {
Miner(MinerUnit),
Miner(MinerUnit),
}
impl Units {
#[inline]
pub fn u(&self) -> &dyn Unit {
match self {
Self::Miner(m) => m,
}
#[inline]
pub fn u(&self) -> &dyn Unit {
match self {
Self::Miner(m) => m,
}
}
#[inline]
pub fn u_mut(&mut self) -> &mut dyn Unit {
match self {
Self::Miner(m) => m,
}
#[inline]
pub fn u_mut(&mut self) -> &mut dyn Unit {
match self {
Self::Miner(m) => m,
}
}
}
impl Unit for Units {
fn get_tag(&self) -> char {
self.u().get_tag()
}
fn get_tag(&self) -> char {
self.u().get_tag()
}
fn get_name(&self) -> &'static str {
self.u().get_name()
}
fn get_name(&self) -> &'static str {
self.u().get_name()
}
fn get_owner(&self) -> Players {
self.u().get_owner()
}
fn get_owner(&self) -> Players {
self.u().get_owner()
}
fn get_hp(&self) -> u16 {
self.u().get_hp()
}
fn get_hp(&self) -> u16 {
self.u().get_hp()
}
fn get_max_hp(&self) -> u16 {
self.u().get_max_hp()
}
fn get_max_hp(&self) -> u16 {
self.u().get_max_hp()
}
fn get_can_dig(&self) -> bool {
self.u().get_can_dig()
}
fn get_can_dig(&self) -> bool {
self.u().get_can_dig()
}
fn get_digging_power(&self) -> f32 {
self.u().get_digging_power()
}
fn get_digging_power(&self) -> f32 {
self.u().get_digging_power()
}
fn get_coords(&self) -> (usize, usize) {
self.u().get_coords()
}
fn get_coords(&self) -> (usize, usize) {
self.u().get_coords()
}
fn set_coords(&mut self, coords: (usize, usize)) {
self.u_mut().set_coords(coords);
}
fn set_coords(&mut self, coords: (usize, usize)) {
self.u_mut().set_coords(coords);
}
fn get_ref_tasks(&self) -> &VecDeque<Tasks> {
self.u().get_ref_tasks()
}
fn get_ref_tasks(&self) -> &VecDeque<Tasks> {
self.u().get_ref_tasks()
}
fn get_mut_tasks(&mut self) -> &mut VecDeque<Tasks> {
self.u_mut().get_mut_tasks()
}
fn get_mut_tasks(&mut self) -> &mut VecDeque<Tasks> {
self.u_mut().get_mut_tasks()
}
fn get_tasks_formatted(&self) -> Vec<Line<'_>> {
self.u().get_tasks_formatted()
}
fn get_tasks_formatted(&self) -> Vec<Line<'_>> {
self.u().get_tasks_formatted()
}
fn set_task(&mut self, task: Tasks) {
self.u_mut().set_task(task);
}
fn set_task(&mut self, task: Tasks) {
self.u_mut().set_task(task);
}
}
impl Unit for Option<Units> {
fn is_unit(&self) -> bool {
self.as_ref().map_or(false, |u| u.is_unit())
}
fn is_unit(&self) -> bool {
self.as_ref().map_or(false, |u| u.is_unit())
}
fn get_tag(&self) -> char {
self.as_ref().map_or(' ', |u| u.get_tag())
}
fn get_tag(&self) -> char {
self.as_ref().map_or(' ', |u| u.get_tag())
}
fn get_name(&self) -> &'static str {
self.as_ref().map_or("", |u| u.get_name())
}
fn get_name(&self) -> &'static str {
self.as_ref().map_or("", |u| u.get_name())
}
fn get_owner(&self) -> Players {
self.as_ref().map_or(Players::Unclaimed, |u| u.get_owner())
}
fn get_owner(&self) -> Players {
self.as_ref().map_or(Players::Unclaimed, |u| u.get_owner())
}
fn get_hp(&self) -> u16 {
self.as_ref().map_or(0, |u| u.get_hp())
}
fn get_hp(&self) -> u16 {
self.as_ref().map_or(0, |u| u.get_hp())
}
fn get_max_hp(&self) -> u16 {
self.as_ref().map_or(0, |u| u.get_max_hp())
}
fn get_max_hp(&self) -> u16 {
self.as_ref().map_or(0, |u| u.get_max_hp())
}
fn get_can_dig(&self) -> bool {
self.as_ref().map_or(false, |u| u.get_can_dig())
}
fn get_can_dig(&self) -> bool {
self.as_ref().map_or(false, |u| u.get_can_dig())
}
fn get_digging_power(&self) -> f32 {
self.as_ref().map_or(0.0, |u| u.get_digging_power())
}
fn get_digging_power(&self) -> f32 {
self.as_ref().map_or(0.0, |u| u.get_digging_power())
}
fn get_coords(&self) -> (usize, usize) {
self.as_ref().map_or((0, 0), |u| u.get_coords())
}
fn get_coords(&self) -> (usize, usize) {
self.as_ref().map_or((0, 0), |u| u.get_coords())
}
fn set_coords(&mut self, coords: (usize, usize)) {
if let Some(unit) = self.as_mut() {
unit.set_coords(coords);
}
fn set_coords(&mut self, coords: (usize, usize)) {
if let Some(unit) = self.as_mut() {
unit.set_coords(coords);
}
}
fn get_ref_tasks(&self) -> &VecDeque<Tasks> {
self.as_ref()
.expect("attempted to get referenced tasks from `None`")
.get_ref_tasks()
}
fn get_ref_tasks(&self) -> &VecDeque<Tasks> {
self
.as_ref()
.expect("attempted to get referenced tasks from `None`")
.get_ref_tasks()
}
fn get_mut_tasks(&mut self) -> &mut VecDeque<Tasks> {
self.as_mut()
.expect("attempted to get mutable tasks from `None`")
.get_mut_tasks()
}
fn get_mut_tasks(&mut self) -> &mut VecDeque<Tasks> {
self
.as_mut()
.expect("attempted to get mutable tasks from `None`")
.get_mut_tasks()
}
fn get_tasks_formatted(&self) -> Vec<Line<'_>> {
self.as_ref()
.map_or(Vec::new(), |u| u.get_tasks_formatted())
}
fn get_tasks_formatted(&self) -> Vec<Line<'_>> {
self
.as_ref()
.map_or(Vec::new(), |u| u.get_tasks_formatted())
}
fn set_task(&mut self, task: Tasks) {
self.as_mut().map_or((), |u| u.set_task(task))
}
fn set_task(&mut self, task: Tasks) {
self.as_mut().map_or((), |u| u.set_task(task))
}
}