pub struct DebugMap<'a> { /* private fields */ }Expand description
A helper designed to assist with creation of
DebugPls implementations for maps.
§Examples
use dbg_pls::{pretty, DebugPls, Formatter};
use std::collections::BTreeMap;
struct Foo(BTreeMap<String, i32>);
impl DebugPls for Foo {
fn fmt(&self, f: Formatter) {
f.debug_map().entries(&self.0).finish()
}
}
let mut value = Foo(BTreeMap::from([
("Hello".to_string(), 5),
("World".to_string(), 10),
]));
assert_eq!(
format!("{}", pretty(&value)),
"{
\"Hello\" = 5;
\"World\" = 10;
}",
);Implementations§
Source§impl<'a> DebugMap<'a>
impl<'a> DebugMap<'a>
Sourcepub fn key(self, key: &dyn DebugPls) -> Self
pub fn key(self, key: &dyn DebugPls) -> Self
Adds the key part to the map output.
§Panics
key must be called before value and each call to key must be followed
by a corresponding call to value. Otherwise this method will panic.
Sourcepub fn value(self, value: &dyn DebugPls) -> Self
pub fn value(self, value: &dyn DebugPls) -> Self
Adds the value part to the map output.
§Panics
key must be called before value and each call to key must be followed
by a corresponding call to value. Otherwise this method will panic.
Sourcepub fn entry(self, key: &dyn DebugPls, value: &dyn DebugPls) -> Self
pub fn entry(self, key: &dyn DebugPls, value: &dyn DebugPls) -> Self
Adds the entry to the map output.
Auto Trait Implementations§
impl<'a> Freeze for DebugMap<'a>
impl<'a> RefUnwindSafe for DebugMap<'a>
impl<'a> !Send for DebugMap<'a>
impl<'a> !Sync for DebugMap<'a>
impl<'a> Unpin for DebugMap<'a>
impl<'a> !UnwindSafe for DebugMap<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more