mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Use debug_map to implement Debug
This commit is contained in:
@ -16,7 +16,7 @@ use lazy_static::lazy_static;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{
|
use std::{
|
||||||
convert::{TryFrom, TryInto},
|
convert::{TryFrom, TryInto},
|
||||||
fmt::{self, Write},
|
fmt,
|
||||||
marker::PhantomData,
|
marker::PhantomData,
|
||||||
ops::{Index, IndexMut},
|
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> {
|
impl<V: Default + Copy + PartialEq + fmt::Debug> fmt::Debug for GoodMap<V> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.write_str("{ ")?;
|
f.debug_map()
|
||||||
for i in self.iter() {
|
.entries(
|
||||||
if *i.1 != V::default() {
|
self.iter()
|
||||||
Good::from(i.0).fmt(f)?;
|
.filter(|i| *i.1 != V::default())
|
||||||
f.write_char(':')?;
|
.map(|i| (Good::from(i.0), i.1)),
|
||||||
i.1.fmt(f)?;
|
)
|
||||||
f.write_char(' ')?;
|
.finish()
|
||||||
}
|
|
||||||
}
|
|
||||||
f.write_char('}')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,16 +213,13 @@ impl<V: Default + Copy> Default for LaborMap<V> {
|
|||||||
|
|
||||||
impl<V: Default + Copy + PartialEq + fmt::Debug> fmt::Debug for LaborMap<V> {
|
impl<V: Default + Copy + PartialEq + fmt::Debug> fmt::Debug for LaborMap<V> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.write_str("{ ")?;
|
f.debug_map()
|
||||||
for i in self.iter() {
|
.entries(
|
||||||
if *i.1 != V::default() {
|
self.iter()
|
||||||
i.0.fmt(f)?;
|
.filter(|i| *i.1 != V::default())
|
||||||
f.write_char(':')?;
|
.map(|i| (i.0, &*i.1)),
|
||||||
(*i.1).fmt(f)?;
|
)
|
||||||
f.write_char(' ')?;
|
.finish()
|
||||||
}
|
|
||||||
}
|
|
||||||
f.write_char('}')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user