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§

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.

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.

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.

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.

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§

Returns a reference to the element at the cursor’s current position, or None if the underlying vector is empty. Enable the "optionless-accessors" feature to remove the Option from the return type, see usage notes. Read more
Returns the handle of the element at the cursor’s current position. Read more
Moves the cursor to the specified handle. The handle must be valid. Returns true if the move was successful. If the "optionless-accessors" feature is enabled, this method doesn’t return a value. This feature is disabled by default, see usage notes. Read more
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. Read more
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. Read more
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. Read more
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. Read more
👎Deprecated since 1.1.0: Use move_to_front() instead.
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. Read more
👎Deprecated since 1.1.0: Use move_to_back() instead.
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. Read more
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 did not move forward by the specified amount. The handle at the current position after the move is returned in either Result variant. Read more
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 did not move backward by the specified amount. The handle at the current position after the move is returned in either Result variant. Read more
The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

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