1use crate::Map;
2use core::fmt::{self, Debug, Formatter};
3
4impl<K: PartialEq + Debug, V: Debug, const N: usize> Debug for Map<K, V, N> {
5 fn fmt(
6 &self,
7 f: &mut Formatter,
8 ) -> fmt::Result {
9 f.debug_map().entries(self.iter()).finish()
10 }
11}
12
13#[cfg(test)]
14mod test {
15 use super::*;
16
17 #[test]
18 fn debugs_map() {
19 let mut m: Map<String, i32, 10> = Map::new();
20 m.insert("one".to_string(), 42);
21 m.insert("two".to_string(), 16);
22 assert_eq!(r#"{"one": 42, "two": 16}"#, format!("{:?}", m));
23 }
24
25 #[test]
26 fn debug_alternate_map() {
27 let mut m: Map<String, i32, 10> = Map::new();
28 m.insert("one".to_string(), 42);
29 m.insert("two".to_string(), 16);
30 assert_eq!(
31 r#"{
32 "one": 42,
33 "two": 16,
34}"#,
35 format!("{:#?}", m)
36 );
37 }
38}