chore: fix clippy errors, add allow dead_code modifiers

This commit is contained in:
2025-07-28 20:53:01 -05:00
parent 324c358672
commit 4398ec2936
6 changed files with 32 additions and 5 deletions

View File

@@ -33,7 +33,7 @@ pub struct App<'a> {
last_tick: Instant, last_tick: Instant,
} }
impl<'a> App<'a> { impl App<'_> {
pub fn new() -> Result<Self> { pub fn new() -> Result<Self> {
let sdl_context = sdl2::init().map_err(|e| anyhow!(e))?; let sdl_context = sdl2::init().map_err(|e| anyhow!(e))?;
let video_subsystem = sdl_context.video().map_err(|e| anyhow!(e))?; let video_subsystem = sdl_context.video().map_err(|e| anyhow!(e))?;

View File

@@ -157,6 +157,7 @@ impl Audio {
} }
/// Returns `true` if the audio system is disabled. /// Returns `true` if the audio system is disabled.
#[allow(dead_code)]
pub fn is_disabled(&self) -> bool { pub fn is_disabled(&self) -> bool {
self.disabled self.disabled
} }

View File

@@ -11,6 +11,8 @@ use sdl2::render::{Canvas, RenderTarget};
use std::collections::{HashMap, VecDeque}; use std::collections::{HashMap, VecDeque};
use tracing::debug; use tracing::debug;
/// The starting positions of the entities in the game.
#[allow(dead_code)]
pub struct NodePositions { pub struct NodePositions {
pub pacman: NodeId, pub pacman: NodeId,
pub blinky: NodeId, pub blinky: NodeId,
@@ -22,12 +24,14 @@ pub struct NodePositions {
/// The main map structure containing the game board and navigation graph. /// The main map structure containing the game board and navigation graph.
pub struct Map { pub struct Map {
/// The current state of the map. /// The current state of the map.
#[allow(dead_code)]
current: [[MapTile; BOARD_CELL_SIZE.y as usize]; BOARD_CELL_SIZE.x as usize], current: [[MapTile; BOARD_CELL_SIZE.y as usize]; BOARD_CELL_SIZE.x as usize],
/// The node map for entity movement. /// The node map for entity movement.
pub graph: Graph, pub graph: Graph,
/// A mapping from grid positions to node IDs. /// A mapping from grid positions to node IDs.
pub grid_to_node: HashMap<IVec2, NodeId>, pub grid_to_node: HashMap<IVec2, NodeId>,
/// A mapping of the starting positions of the entities. /// A mapping of the starting positions of the entities.
#[allow(dead_code)]
pub start_positions: NodePositions, pub start_positions: NodePositions,
/// Pac-Man's starting position. /// Pac-Man's starting position.
pacman_start: Option<IVec2>, pacman_start: Option<IVec2>,

View File

@@ -50,19 +50,26 @@ impl AnimatedTexture {
tile.render(canvas, atlas, dest) tile.render(canvas, atlas, dest)
} }
// Helper methods for testing /// Returns the current frame index.
#[allow(dead_code)]
pub fn current_frame(&self) -> usize { pub fn current_frame(&self) -> usize {
self.current_frame self.current_frame
} }
/// Returns the time bank.
#[allow(dead_code)]
pub fn time_bank(&self) -> f32 { pub fn time_bank(&self) -> f32 {
self.time_bank self.time_bank
} }
/// Returns the frame duration.
#[allow(dead_code)]
pub fn frame_duration(&self) -> f32 { pub fn frame_duration(&self) -> f32 {
self.frame_duration self.frame_duration
} }
/// Returns the number of tiles in the animation.
#[allow(dead_code)]
pub fn tiles_len(&self) -> usize { pub fn tiles_len(&self) -> usize {
self.tiles.len() self.tiles.len()
} }

View File

@@ -55,19 +55,26 @@ impl DirectionalAnimatedTexture {
} }
} }
// Helper methods for testing /// Returns true if the texture has a direction.
#[allow(dead_code)]
pub fn has_direction(&self, direction: Direction) -> bool { pub fn has_direction(&self, direction: Direction) -> bool {
self.textures.contains_key(&direction) self.textures.contains_key(&direction)
} }
/// Returns true if the texture has a stopped direction.
#[allow(dead_code)]
pub fn has_stopped_direction(&self, direction: Direction) -> bool { pub fn has_stopped_direction(&self, direction: Direction) -> bool {
self.stopped_textures.contains_key(&direction) self.stopped_textures.contains_key(&direction)
} }
/// Returns the number of textures.
#[allow(dead_code)]
pub fn texture_count(&self) -> usize { pub fn texture_count(&self) -> usize {
self.textures.len() self.textures.len()
} }
/// Returns the number of stopped textures.
#[allow(dead_code)]
pub fn stopped_texture_count(&self) -> usize { pub fn stopped_texture_count(&self) -> usize {
self.stopped_textures.len() self.stopped_textures.len()
} }

View File

@@ -50,11 +50,14 @@ impl AtlasTile {
Ok(()) Ok(())
} }
// Helper methods for testing /// Creates a new atlas tile.
#[allow(dead_code)]
pub fn new(pos: U16Vec2, size: U16Vec2, color: Option<Color>) -> Self { pub fn new(pos: U16Vec2, size: U16Vec2, color: Option<Color>) -> Self {
Self { pos, size, color } Self { pos, size, color }
} }
/// Sets the color of the tile.
#[allow(dead_code)]
pub fn with_color(mut self, color: Color) -> Self { pub fn with_color(mut self, color: Color) -> Self {
self.color = Some(color); self.color = Some(color);
self self
@@ -96,15 +99,20 @@ impl SpriteAtlas {
&self.texture &self.texture
} }
// Helper methods for testing /// Returns the number of tiles in the atlas.
#[allow(dead_code)]
pub fn tiles_count(&self) -> usize { pub fn tiles_count(&self) -> usize {
self.tiles.len() self.tiles.len()
} }
/// Returns true if the atlas has a tile with the given name.
#[allow(dead_code)]
pub fn has_tile(&self, name: &str) -> bool { pub fn has_tile(&self, name: &str) -> bool {
self.tiles.contains_key(name) self.tiles.contains_key(name)
} }
/// Returns the default color of the atlas.
#[allow(dead_code)]
pub fn default_color(&self) -> Option<Color> { pub fn default_color(&self) -> Option<Color> {
self.default_color self.default_color
} }