From 81f28bc3cc41da789301802c83215f6d0b2208df Mon Sep 17 00:00:00 2001
From: notoria <notoria@users.noreply.github.com>
Date: Mon, 6 Dec 2021 23:33:34 +0100
Subject: [PATCH] Use debug_map to implement Debug

---
 world/src/site/economy.rs | 36 +++++++++++++++---------------------
 1 file changed, 15 insertions(+), 21 deletions(-)

diff --git a/world/src/site/economy.rs b/world/src/site/economy.rs
index 11afd2ff4b..e3a01bfe06 100644
--- a/world/src/site/economy.rs
+++ b/world/src/site/economy.rs
@@ -16,7 +16,7 @@ use lazy_static::lazy_static;
 use serde::{Deserialize, Serialize};
 use std::{
     convert::{TryFrom, TryInto},
-    fmt::{self, Write},
+    fmt,
     marker::PhantomData,
     ops::{Index, IndexMut},
 };
@@ -98,16 +98,13 @@ impl<V: Default + Copy> Default for GoodMap<V> {
 
 impl<V: Default + Copy + PartialEq + fmt::Debug> fmt::Debug for GoodMap<V> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.write_str("{ ")?;
-        for i in self.iter() {
-            if *i.1 != V::default() {
-                Good::from(i.0).fmt(f)?;
-                f.write_char(':')?;
-                i.1.fmt(f)?;
-                f.write_char(' ')?;
-            }
-        }
-        f.write_char('}')
+        f.debug_map()
+            .entries(
+                self.iter()
+                    .filter(|i| *i.1 != V::default())
+                    .map(|i| (Good::from(i.0), i.1)),
+            )
+            .finish()
     }
 }
 
@@ -216,16 +213,13 @@ impl<V: Default + Copy> Default for LaborMap<V> {
 
 impl<V: Default + Copy + PartialEq + fmt::Debug> fmt::Debug for LaborMap<V> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.write_str("{ ")?;
-        for i in self.iter() {
-            if *i.1 != V::default() {
-                i.0.fmt(f)?;
-                f.write_char(':')?;
-                (*i.1).fmt(f)?;
-                f.write_char(' ')?;
-            }
-        }
-        f.write_char('}')
+        f.debug_map()
+            .entries(
+                self.iter()
+                    .filter(|i| *i.1 != V::default())
+                    .map(|i| (i.0, &*i.1)),
+            )
+            .finish()
     }
 }