Struct intrusive_collections::linked_list::CursorMut

source ·
pub struct CursorMut<'a, A: Adapter>{ /* private fields */ }
Expand description

A cursor which provides mutable access to a LinkedList.

Implementations§

source§

impl<'a, A: Adapter> CursorMut<'a, A>

source

pub fn is_null(&self) -> bool

Checks if the cursor is currently pointing to the null object.

source

pub fn get(&self) -> Option<&<A::PointerOps as PointerOps>::Value>

Returns a reference to the object that the cursor is currently pointing to.

This returns None if the cursor is currently pointing to the null object.

source

pub fn as_cursor(&self) -> Cursor<'_, A>

Returns a read-only cursor pointing to the current element.

The lifetime of the returned Cursor is bound to that of the CursorMut, which means it cannot outlive the CursorMut and that the CursorMut is frozen for the lifetime of the Cursor.

source

pub fn move_next(&mut self)

Moves the cursor to the next element of the LinkedList.

If the cursor is pointer to the null object then this will move it to the first element of the LinkedList. If it is pointing to the last element of the LinkedList then this will move it to the null object.

source

pub fn move_prev(&mut self)

Moves the cursor to the previous element of the LinkedList.

If the cursor is pointer to the null object then this will move it to the last element of the LinkedList. If it is pointing to the first element of the LinkedList then this will move it to the null object.

source

pub fn peek_next(&self) -> Cursor<'_, A>

Returns a cursor pointing to the next element of the LinkedList.

If the cursor is pointer to the null object then this will return the first element of the LinkedList. If it is pointing to the last element of the LinkedList then this will return a null cursor.

source

pub fn peek_prev(&self) -> Cursor<'_, A>

Returns a cursor pointing to the previous element of the LinkedList.

If the cursor is pointer to the null object then this will return the last element of the LinkedList. If it is pointing to the first element of the LinkedList then this will return a null cursor.

source

pub fn remove(&mut self) -> Option<<A::PointerOps as PointerOps>::Pointer>

Removes the current element from the LinkedList.

A pointer to the element that was removed is returned, and the cursor is moved to point to the next element in the LinkedList.

If the cursor is currently pointing to the null object then no element is removed and None is returned.

source

pub fn replace_with( &mut self, val: <A::PointerOps as PointerOps>::Pointer, ) -> Result<<A::PointerOps as PointerOps>::Pointer, <A::PointerOps as PointerOps>::Pointer>

Removes the current element from the LinkedList and inserts another object in its place.

A pointer to the element that was removed is returned, and the cursor is modified to point to the newly added element.

If the cursor is currently pointing to the null object then an error is returned containing the given val parameter.

§Panics

Panics if the new element is already linked to a different intrusive collection.

source

pub fn insert_after(&mut self, val: <A::PointerOps as PointerOps>::Pointer)

Inserts a new element into the LinkedList after the current one.

If the cursor is pointing at the null object then the new element is inserted at the front of the LinkedList.

§Panics

Panics if the new element is already linked to a different intrusive collection.

source

pub fn insert_before(&mut self, val: <A::PointerOps as PointerOps>::Pointer)

Inserts a new element into the LinkedList before the current one.

If the cursor is pointing at the null object then the new element is inserted at the end of the LinkedList.

§Panics

Panics if the new element is already linked to a different intrusive collection.

source

pub fn splice_after(&mut self, list: LinkedList<A>)

Inserts the elements from the given LinkedList after the current one.

If the cursor is pointing at the null object then the new elements are inserted at the start of the LinkedList.

source

pub fn splice_before(&mut self, list: LinkedList<A>)

Moves all element from the given LinkedList before the current one.

If the cursor is pointing at the null object then the new elements are inserted at the end of the LinkedList.

source

pub fn split_after(&mut self) -> LinkedList<A>
where A: Clone,

Splits the list into two after the current element. This will return a new list consisting of everything after the cursor, with the original list retaining everything before.

If the cursor is pointing at the null object then the entire contents of the LinkedList are moved.

source

pub fn split_before(&mut self) -> LinkedList<A>
where A: Clone,

Splits the list into two before the current element. This will return a new list consisting of everything before the cursor, with the original list retaining everything after.

If the cursor is pointing at the null object then the entire contents of the LinkedList are moved.

source

pub fn into_ref(self) -> Option<&'a <A::PointerOps as PointerOps>::Value>

Consumes CursorMut and returns a reference to the object that the cursor is currently pointing to. Unlike get, the returned reference’s lifetime is tied to LinkedList’s lifetime.

This returns None if the cursor is currently pointing to the null object.

Auto Trait Implementations§

§

impl<'a, A> Freeze for CursorMut<'a, A>
where <<A as Adapter>::LinkOps as LinkOps>::LinkPtr: Freeze,

§

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

§

impl<'a, A> Send for CursorMut<'a, A>
where <<A as Adapter>::LinkOps as LinkOps>::LinkPtr: Send, A: Send, <<A as Adapter>::PointerOps as PointerOps>::Pointer: Send,

§

impl<'a, A> Sync for CursorMut<'a, A>
where <<A as Adapter>::LinkOps as LinkOps>::LinkPtr: Sync, A: Sync, <<A as Adapter>::PointerOps as PointerOps>::Value: Sync,

§

impl<'a, A> Unpin for CursorMut<'a, A>
where <<A as Adapter>::LinkOps as LinkOps>::LinkPtr: Unpin,

§

impl<'a, A> !UnwindSafe for CursorMut<'a, 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.