From cc76207b755180676e1a53aa2e0269cf23afa5c6 Mon Sep 17 00:00:00 2001 From: Eray Erdin Date: Sat, 3 Aug 2024 23:16:38 +0300 Subject: [PATCH] impl fmt::Debug for Map manually --- src/map.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/map.rs b/src/map.rs index 93a851eb..92ed0c1e 100644 --- a/src/map.rs +++ b/src/map.rs @@ -19,7 +19,7 @@ pub(crate) struct MapTilesetGid { } /// All Tiled map files will be parsed into this. Holds all the layers and tilesets. -#[derive(PartialEq, Clone, Debug)] +#[derive(PartialEq, Clone)] pub struct Map { version: String, /// The way tiles are laid out in the map. @@ -65,6 +65,27 @@ pub struct Map { pub user_type: Option, } +impl fmt::Debug for Map { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Map") + .field("version", &self.version) + .field("orientation", &self.orientation) + .field("width", &self.width) + .field("height", &self.height) + .field("tile_width", &self.tile_width) + .field("tile_height", &self.tile_height) + .field("stagger_axis", &self.stagger_axis) + .field("stagger_index", &self.stagger_index) + .field("tilesets", &format!("{} tilesets", self.tilesets.len())) + .field("layers", &format!("{} layers", self.layers.len())) + .field("properties", &self.properties) + .field("background_color", &self.background_color) + .field("infinite", &self.infinite) + .field("user_type", &self.user_type) + .finish() + } +} + impl Map { /// The TMX format version this map was saved to. Equivalent to the map file's `version` /// attribute.