CursorMut

Struct CursorMut 

Source
pub struct CursorMut<'list, T: ?Sized + Types> { /* private fields */ }
Expand description

A unique cursor into a linked list.

This can be created by methods like PinList::cursor_ghost_mut.

Each cursor conceptually points to a single item in the list. It can also point to the space between the start and end of the list, in which case it is called the ghost cursor.

Implementations§

Source§

impl<'list, T: ?Sized + Types> CursorMut<'list, T>

Source

pub fn into_shared(self) -> Cursor<'list, T>

Downgrade this cursor to its shared form.

Source

pub fn as_shared(&self) -> Cursor<'_, T>

Reborrow this cursor as its shared form.

Note that reborrowing this cursor as another CursorMut is disallowed because it would allow invalidating this cursor while it still exists.

Source

pub fn move_next(&mut self)

Move the cursor to the next element in the linked list.

Source

pub fn move_previous(&mut self)

Move the cursor to the previous element in the linked list.

Source

pub fn list(&self) -> &PinList<T>

Retrieve a shared reference to the list this cursor uses.

Source

pub fn protected(&self) -> Option<&T::Protected>

Retrieve a shared reference to the protected data of this linked list node.

Returns None if the cursor is currently the ghost cursor.

Source

pub fn protected_mut(&mut self) -> Option<&mut T::Protected>

Retrieve a unique reference to the protected data of this linked list node.

Returns None if the cursor is currently the ghost cursor.

Source

pub fn unprotected(&self) -> Option<&T::Unprotected>

Retrieve a shared reference to the unprotected data of this linked list node.

Returns None if the cursor is currently the ghost cursor.

Source

pub fn insert_before<'node>( &mut self, node: Pin<&'node mut Node<T>>, protected: T::Protected, unprotected: T::Unprotected, ) -> Pin<&'node mut InitializedNode<'node, T>>

Insert a node into the linked list before this one.

§Panics

Panics if the node is not in its initial state.

Source

pub fn insert_after<'node>( &mut self, node: Pin<&'node mut Node<T>>, protected: T::Protected, unprotected: T::Unprotected, ) -> Pin<&'node mut InitializedNode<'node, T>>

Insert a node into the linked list after this one.

§Panics

Panics if the node is not in its initial state.

Source

pub fn push_front<'node>( &mut self, node: Pin<&'node mut Node<T>>, protected: T::Protected, unprotected: T::Unprotected, ) -> Pin<&'node mut InitializedNode<'node, T>>

Append a node to the front of the list.

§Panics

Panics if the node is not in its initial state.

Source

pub fn push_back<'node>( &mut self, node: Pin<&'node mut Node<T>>, protected: T::Protected, unprotected: T::Unprotected, ) -> Pin<&'node mut InitializedNode<'node, T>>

Append a node to the back of the list.

§Panics

Panics if the node is not in its initial state.

Source

pub fn remove_current( &mut self, removed: T::Removed, ) -> Result<T::Protected, T::Removed>

Remove this node from the linked list with a given “removed” value.

The cursor is moved to point to the next element in the linked list.

§Errors

Fails if the cursor is currently the ghost cursor (not over an item).

Source

pub fn remove_current_with<F>(&mut self, f: F) -> bool
where F: FnOnce(T::Protected) -> T::Removed,

Remove this node from the linked list, computing its “removed” value from a closure.

The cursor is moved to point to the next element in the linked list.

If the given closure panics, the process will abort.

Returns whether the operation was successful — it fails if the cursor is currently a ghost cursor (not over an item).

Source

pub fn remove_current_with_or<F, Fallback>( &mut self, f: F, fallback: Fallback, ) -> bool
where F: FnOnce(T::Protected) -> T::Removed, Fallback: FnOnce() -> T::Removed,

Remove this node from the linked list, computing its “removed” value from a closure, or using a secondary closure should the first panic. If the secondary closure panics, the process will abort.

The cursor is moved to point to the next element in the linked list.

Returns whether the operation was successful — it fails if the cursor is currently a ghost cursor (not over an item).

Trait Implementations§

Source§

impl<T: ?Sized + Types> Debug for CursorMut<'_, T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T: ?Sized + Types> Send for CursorMut<'_, T>
where PinList<T>: Send,

Source§

impl<T: ?Sized + Types> Sync for CursorMut<'_, T>
where PinList<T>: Sync,

Auto Trait Implementations§

§

impl<'list, T> Freeze for CursorMut<'list, T>
where T: ?Sized,

§

impl<'list, T> !RefUnwindSafe for CursorMut<'list, T>

§

impl<'list, T> Unpin for CursorMut<'list, T>
where T: ?Sized,

§

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

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.