From 3efd5859f53817a0df1eeb7e9317cdc85b62bb61 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Mon, 10 Nov 2025 22:10:52 -0500 Subject: use fmt fns directly when possible --- Cargo.toml | 7 ++++--- dungeon/src/map.rs | 6 +++--- dungeon/src/pos.rs | 8 ++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7d7f8da..59d7251 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -85,6 +85,7 @@ lto = "fat" codegen-units = 1 panic = "abort" strip = "symbols" -debug = false -incremental = false -overflow-checks = false + +[profile.small] +inherits = "release" +opt-level = "z" diff --git a/dungeon/src/map.rs b/dungeon/src/map.rs index 19c1de8..4e1f235 100644 --- a/dungeon/src/map.rs +++ b/dungeon/src/map.rs @@ -1,7 +1,7 @@ //! The `map` module contains structures of the dungeon game map //! including the current `Floor`, and map `Tile`. -use rand::{rngs::StdRng, Rng, SeedableRng, TryRngCore}; +use rand::{Rng, SeedableRng, TryRngCore, rngs::StdRng}; use strum::IntoEnumIterator; use strum_macros::EnumIter; @@ -265,10 +265,10 @@ impl Display for Floor { } // Otherwise, show the tile character let tile = self.get(pos); - write!(f, "{tile}")?; + tile.fmt(f)?; // Newline at the end of each row if pos.xy().0 == MAP_SIZE - 1 { - writeln!(f)?; + f.write_char('\n')?; } } diff --git a/dungeon/src/pos.rs b/dungeon/src/pos.rs index 623d914..47732a0 100644 --- a/dungeon/src/pos.rs +++ b/dungeon/src/pos.rs @@ -75,10 +75,10 @@ impl Direction { impl Display for Direction { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Self::North => write!(f, "NORTH"), - Self::South => write!(f, "SOUTH"), - Self::East => write!(f, "EAST"), - Self::West => write!(f, "WEST"), + Self::North => f.write_str("NORTH"), + Self::South => f.write_str("SOUTH"), + Self::East => f.write_str("EAST"), + Self::West => f.write_str("WEST"), } } } -- cgit v1.2.3-freya