pub struct ManagedInspectMap<V> { /* private fields */ }
Expand description
A map that wraps an inspect node and attaches all inserted values to the node.
This class can either be explicitly given an inspect node through ManagedInspectMap::with_node or can create its own inspect node when included in a struct that derives Inspect or when [ManagedInspectMap::with_inspect] is called.
Implementations§
Source§impl<V> ManagedInspectMap<V>
impl<V> ManagedInspectMap<V>
Sourcepub fn with_node(node: Node) -> Self
pub fn with_node(node: Node) -> Self
Creates a new ManagedInspectMap that attaches inserted values to the given node.
Sourcepub fn map(&self) -> &HashMap<String, V>
pub fn map(&self) -> &HashMap<String, V>
Returns a reference to the underlying map. Clients should not insert values into the map through this reference.
Sourcepub fn map_mut(&mut self) -> &mut HashMap<String, V>
pub fn map_mut(&mut self) -> &mut HashMap<String, V>
Returns a mutable reference to the underlying map. Clients should not insert values into the map through this reference.
Sourcepub fn insert(&mut self, key: String, value: V) -> Option<V>
pub fn insert(&mut self, key: String, value: V) -> Option<V>
Inserts the given value into the map and attach it to the inspect tree. Returns the previous value with the given key, if any.
Sourcepub fn insert_with_property_name(
&mut self,
map_key: String,
property_name: String,
value: V,
) -> Option<V>
pub fn insert_with_property_name( &mut self, map_key: String, property_name: String, value: V, ) -> Option<V>
Inserts the given value into the map and attaches it to the inspect tree with a different name. Returns the previous value with the given map key, if any.
This is useful for cases where the unique key for the map is not useful for actually recording to inspect.
Sourcepub fn get_or_insert_with(
&mut self,
key: String,
value: impl FnOnce() -> V,
) -> &mut V
pub fn get_or_insert_with( &mut self, key: String, value: impl FnOnce() -> V, ) -> &mut V
Returns a mutable reference to the value at the given key, inserting a value if not present.
Sourcepub fn get_mut(&mut self, key: &str) -> Option<&mut V>
pub fn get_mut(&mut self, key: &str) -> Option<&mut V>
Returns a mutable reference to the entry at key
.
Sourcepub fn inspect_node(&self) -> &Node
pub fn inspect_node(&self) -> &Node
Returns a reference to the inspect node associated with this map.