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

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.

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.

Adds the entry to the map output.

Adds all the entries to the map output.

Closes off the map.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.