pub struct CursorMut<'a, K: 'a, V: 'a, A = Global> { /* private fields */ }
Expand description
A cursor over a BTreeMap
with editing operations.
A Cursor
is like an iterator, except that it can freely seek back-and-forth, and can
safely mutate the tree during iteration. This is because the lifetime of its yielded
references is tied to its own lifetime, instead of just the underlying tree. This means
cursors cannot yield multiple elements at once.
Cursors always point to an element in the tree, and index in a logically circular way.
To accommodate this, there is a “ghost” non-element that yields None
between the last and
first elements of the tree.
A Cursor
is created with the BTreeMap::lower_bound_mut
and BTreeMap::upper_bound_mut
methods.
Implementations§
Source§impl<K, V, A> CursorMut<'_, K, V, A>
impl<K, V, A> CursorMut<'_, K, V, A>
Sourcepub fn key(&self) -> Option<&K>
pub fn key(&self) -> Option<&K>
Returns a reference to the key of the element that the cursor is currently pointing to.
This returns None
if the cursor is currently pointing to the “ghost”
non-element.
Sourcepub fn value(&self) -> Option<&V>
pub fn value(&self) -> Option<&V>
Returns a reference to the value of the element that the cursor is currently pointing to.
This returns None
if the cursor is currently pointing to the “ghost”
non-element.
Sourcepub fn key_value(&self) -> Option<(&K, &V)>
pub fn key_value(&self) -> Option<(&K, &V)>
Returns a reference to the key and value of the element that the cursor is currently pointing to.
This returns None
if the cursor is currently pointing to the “ghost”
non-element.
Sourcepub fn value_mut(&mut self) -> Option<&mut V>
pub fn value_mut(&mut self) -> Option<&mut V>
Returns a mutable reference to the value of the element that the cursor is currently pointing to.
This returns None
if the cursor is currently pointing to the “ghost”
non-element.
Sourcepub fn key_value_mut(&mut self) -> Option<(&K, &mut V)>
pub fn key_value_mut(&mut self) -> Option<(&K, &mut V)>
Returns a reference to the key and mutable reference to the value of the element that the cursor is currently pointing to.
This returns None
if the cursor is currently pointing to the “ghost”
non-element.