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>
impl<'list, T: ?Sized + Types> CursorMut<'list, T>
Downgrade this cursor to its shared form.
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.
Sourcepub fn move_previous(&mut self)
pub fn move_previous(&mut self)
Move the cursor to the previous element in the linked list.
Sourcepub fn protected(&self) -> Option<&T::Protected>
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.
Sourcepub fn protected_mut(&mut self) -> Option<&mut T::Protected>
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.
Sourcepub fn unprotected(&self) -> Option<&T::Unprotected>
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.
Sourcepub fn insert_before<'node>(
&mut self,
node: Pin<&'node mut Node<T>>,
protected: T::Protected,
unprotected: T::Unprotected,
) -> Pin<&'node mut InitializedNode<'node, T>>
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.
Sourcepub fn insert_after<'node>(
&mut self,
node: Pin<&'node mut Node<T>>,
protected: T::Protected,
unprotected: T::Unprotected,
) -> Pin<&'node mut InitializedNode<'node, T>>
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.
Sourcepub fn push_front<'node>(
&mut self,
node: Pin<&'node mut Node<T>>,
protected: T::Protected,
unprotected: T::Unprotected,
) -> Pin<&'node mut InitializedNode<'node, T>>
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>>
Sourcepub fn push_back<'node>(
&mut self,
node: Pin<&'node mut Node<T>>,
protected: T::Protected,
unprotected: T::Unprotected,
) -> Pin<&'node mut InitializedNode<'node, T>>
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>>
Sourcepub fn remove_current(
&mut self,
removed: T::Removed,
) -> Result<T::Protected, T::Removed>
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).
Sourcepub fn remove_current_with<F>(&mut self, f: F) -> bool
pub fn remove_current_with<F>(&mut self, f: F) -> bool
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).
Sourcepub fn remove_current_with_or<F, Fallback>(
&mut self,
f: F,
fallback: Fallback,
) -> bool
pub fn remove_current_with_or<F, Fallback>( &mut self, f: F, fallback: Fallback, ) -> bool
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).