pub struct CursorMut<'a, T> { /* private fields */ }
Expand description

A cursor which can read and write the elements of the list.

Implementations§

source§

impl<'a, T> CursorMut<'a, T>

source

pub fn get_mut(&mut self) -> Option<&mut T>

Returns a mutable reference to the element at the cursor’s current position.

source

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.

source

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.

source

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 there was only one item in the vector, the cursor’s position is set to BAD_HANDLE and should no longer be used, or could cause invalid handle panics.

Trait Implementations§

source§

impl<'a, T> CursorBase<T> for CursorMut<'a, T>

source§

fn get(&self) -> Option<&T>

Returns a reference to the element at the cursor’s current position.
source§

fn move_to(&mut self, handle: HNode) -> bool

Moves the cursor to the specified handle. Returns true if the cursor was moved, false if the handle was invalid.
source§

fn move_next(&mut self) -> Option<HNode>

Moves the cursor to the next element. Returns the handle of the next element if the cursor was moved, None if the cursor was already at the end of the list.
source§

fn move_prev(&mut self) -> Option<HNode>

Moves the cursor to the previous element. Returns the handle of the previous element if the cursor was moved, None if the cursor was already at the start of the list.
source§

fn move_to_start(&mut self) -> Option<HNode>

Moves the cursor to the start of the list. Returns the handle of the first element if the cursor was moved, None if the list is empty.
source§

fn move_to_end(&mut self) -> Option<HNode>

Moves the cursor to the end of the list. Returns the handle of the last element if the cursor was moved, None if the list is empty.
source§

fn forward(&mut self, n: usize) -> Result<HNode, HNode>

Moves the cursor forward by the specified number of elements. Returns the handle of the element at the new position if the cursor was moved, Err(handle) if the cursor was already at the end of the list.
source§

fn backward(&mut self, n: usize) -> Result<HNode, HNode>

Moves the cursor backward by the specified number of elements. Returns the handle of the element at the new position if the cursor was moved, Err(handle) if the cursor was already at the start of the list.

Auto Trait Implementations§

§

impl<'a, T> RefUnwindSafe for CursorMut<'a, T>where T: RefUnwindSafe,

§

impl<'a, T> Send for CursorMut<'a, T>where T: Send,

§

impl<'a, T> Sync for CursorMut<'a, T>where T: Sync,

§

impl<'a, T> Unpin for CursorMut<'a, T>

§

impl<'a, T> !UnwindSafe for CursorMut<'a, T>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V