pub struct Cursor<'a, T: Translator, V: Eq> { /* private fields */ }
Expand description
A mutable iterator over the values associated with a translated key, allowing in-place modifications.
The Cursor
provides a way to traverse and modify the linked list of Record
s while maintaining its
structure. It supports:
- Iteration via
next()
to access values. - Modification via
update()
to change the current value. - Insertion via
insert()
to add new values. - Deletion via
delete()
to remove values.
§Safety
- Must call
next()
beforeupdate()
,insert()
, ordelete()
to establish a valid position. - Once
next()
returnsNone
, onlyinsert()
can be called. - Dropping the
Cursor
automatically restores the list structure by reattaching any detachednext
nodes.
If you don’t need advanced functionality, just use insert()
, insert_and_prune()
, or remove()
instead.
Implementations§
Source§impl<'a, T: Translator, V: Eq> Cursor<'a, T, V>
impl<'a, T: Translator, V: Eq> Cursor<'a, T, V>
Sourcepub fn update(&mut self, v: V)
pub fn update(&mut self, v: V)
Updates the value at the current position in the iteration.
Panics if called before next()
or after iteration is complete (Status::Done
phase).
Sourcepub fn next(&mut self) -> Option<&V>
pub fn next(&mut self) -> Option<&V>
Advances the cursor to the next value in the chain, returning a reference to it.
This method must be called before any other operations (insert()
, delete()
, etc.). If
either insert()
or delete()
is called, next()
must be called to set a new active
item. If after insert()
, the next active item is the item after the inserted item. If after
delete()
, the next active item is the item after the deleted item.
Handles transitions between phases and adjusts for deletions. Returns None
when the list is exhausted.
It is safe to call next()
even after it returns None
.
Trait Implementations§
impl<'a, T, V> Send for Cursor<'a, T, V>
Auto Trait Implementations§
impl<'a, T, V> Freeze for Cursor<'a, T, V>
impl<'a, T, V> RefUnwindSafe for Cursor<'a, T, V>
impl<'a, T, V> !Sync for Cursor<'a, T, V>
impl<'a, T, V> Unpin for Cursor<'a, T, V>
impl<'a, T, V> !UnwindSafe for Cursor<'a, T, V>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more