pub struct NodeMap<'a, K, V, A: ValueAdapter<K, V>>{ /* private fields */ }
Expand description
A NodeMap
is a struct with a hash-map like API and is used to
expose attribute and namespace prefix information.
You obtain one through the APIs Xot::attributes
and Xot::namespaces
.
Implementations§
Source§impl<'a, K, V, A: ValueAdapter<K, V>> NodeMap<'a, K, V, A>
impl<'a, K, V, A: ValueAdapter<K, V>> NodeMap<'a, K, V, A>
Sourcepub fn get_node(&self, key: impl Into<K> + Copy) -> Option<Node>
pub fn get_node(&self, key: impl Into<K> + Copy) -> Option<Node>
Get the node representing the value in the map.
This is an attribute or namespace node. This node has the
element node as a parent, even though it’s not in xot.children(parent)
.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of entries in the map, also referred to as its ‘length’.
Sourcepub fn contains_key(&self, key: impl Into<K> + Copy) -> bool
pub fn contains_key(&self, key: impl Into<K> + Copy) -> bool
Return true
if an equivalent to key
exists in the map.
Sourcepub fn get(&self, key: impl Into<K> + Copy) -> Option<&'a V>
pub fn get(&self, key: impl Into<K> + Copy) -> Option<&'a V>
Return a reference to the value stored for key
, if it is present, else None
.
Sourcepub fn iter(&self) -> impl Iterator<Item = (K, &'a V)> + '_
pub fn iter(&self) -> impl Iterator<Item = (K, &'a V)> + '_
An iterator visiting all key-value pairs in insertion order. The iterator element type is
(&'a K, &'a V)
.
Sourcepub fn keys(&self) -> impl Iterator<Item = K> + '_
pub fn keys(&self) -> impl Iterator<Item = K> + '_
An iterator visiting all keys in insertion order. The iterator element type is &'a K
.
Sourcepub fn values(&self) -> impl Iterator<Item = &'a V> + '_
pub fn values(&self) -> impl Iterator<Item = &'a V> + '_
An iterator visiting all values in insertion order. The iterator element type is &'a V
.
Sourcepub fn nodes(&self) -> impl Iterator<Item = Node> + '_
pub fn nodes(&self) -> impl Iterator<Item = Node> + '_
An iterator visiting all the nodes in insertion order.
Sourcepub fn to_hashmap(&self) -> AHashMap<K, V>
pub fn to_hashmap(&self) -> AHashMap<K, V>
Convert into a hashmap
Trait Implementations§
Auto Trait Implementations§
impl<'a, K, V, A> Freeze for NodeMap<'a, K, V, A>
impl<'a, K, V, A> RefUnwindSafe for NodeMap<'a, K, V, A>
impl<'a, K, V, A> Send for NodeMap<'a, K, V, A>
impl<'a, K, V, A> Sync for NodeMap<'a, K, V, A>
impl<'a, K, V, A> Unpin for NodeMap<'a, K, V, A>
impl<'a, K, V, A> UnwindSafe for NodeMap<'a, K, V, 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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more