Skip to content

Commit

Permalink
impl fmt::Debug for Map manually (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
erayerdin authored Aug 4, 2024
1 parent f86e079 commit ab62d91
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -65,6 +65,27 @@ pub struct Map {
pub user_type: Option<String>,
}

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.
Expand Down

0 comments on commit ab62d91

Please sign in to comment.