Struct linked_vector::CursorMut
source · pub struct CursorMut<'a, T> { /* private fields */ }
Expand description
A cursor which can read and write the elements of the list. CursorMut
supports a remove()
method which removes the element at the current
position of the cursor. This feature is turned on with the "cursor-remove"
feature, see usage notes.
Implementations§
source§impl<'a, T> CursorMut<'a, T>
impl<'a, T> CursorMut<'a, T>
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if the vector the cursor is attached to is empty. Since
a mutable cursor can remove items, this is provided as a means to avoid
panics if the cursor is being used to remove items. If the underlying
vector is empty, other operations may panic.
sourcepub fn get_mut(&mut self) -> Option<&mut T>
pub fn get_mut(&mut self) -> Option<&mut T>
Returns a mutable reference to the element at the cursor’s current
position, or None
if the underlying vector is empty. If the
optionless-accessors
feature is enabled, this will return a reference
directly. This feature is disabled by default, see
usage notes.
sourcepub fn insert(&mut self, value: T) -> HNode
pub fn insert(&mut self, value: T) -> HNode
Inserts a new element at the cursor’s current position. The cursor will be moved to the new element. Returns the handle of the new element.
sourcepub fn insert_after(&mut self, value: T) -> HNode
pub fn insert_after(&mut self, value: T) -> HNode
Inserts a new element after the cursor’s current position. The cursor will still be at the same position. Returns the handle of the new element.
sourcepub fn remove(&mut self) -> Option<T>
pub fn remove(&mut self) -> Option<T>
Removes the element at the current position and returns its value. The
cursor will be moved to the next element if not at the end of the
vector, otherwise it moves to the new end. If the vector is already
empty, None
is returned. The "cursor-remove"
feature must be
enabled to use this method, see
usage notes.
Trait Implementations§
source§impl<'a, T> CursorBase<T> for CursorMut<'a, T>
impl<'a, T> CursorBase<T> for CursorMut<'a, T>
source§fn get(&self) -> Option<&T>
fn get(&self) -> Option<&T>
None
if the underlying vector is empty. Enable the
"optionless-accessors"
feature to remove the Option
from the return
type, see usage notes. Read moresource§fn node(&self) -> HNode
fn node(&self) -> HNode
source§fn move_to(&mut self, handle: HNode) -> bool
fn move_to(&mut self, handle: HNode) -> bool
"optionless-accessors"
feature is enabled, this method doesn’t return a value. This feature is
disabled by default, see
usage notes. Read more