rune_alloc::btree_map

Struct CursorMut

Source
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>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<K: Debug, V: Debug, A> Debug for CursorMut<'_, K, V, A>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, K, V, A> Freeze for CursorMut<'a, K, V, A>

§

impl<'a, K, V, A> RefUnwindSafe for CursorMut<'a, K, V, A>

§

impl<'a, K, V, A> Send for CursorMut<'a, K, V, A>
where A: Send, K: Send, V: Send,

§

impl<'a, K, V, A> Sync for CursorMut<'a, K, V, A>
where A: Sync, K: Sync, V: Sync,

§

impl<'a, K, V, A> Unpin for CursorMut<'a, K, V, A>

§

impl<'a, K, V, A = Global> !UnwindSafe for CursorMut<'a, K, V, A>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.