pub struct Cursor<'a, T> {
pub preceding: Option<Preceding<NonNull<Node<T>>>>,
pub current: Option<NonNull<Node<T>>>,
pub root: &'a Option<NonNull<Node<T>>>,
pub succeeding_bound: Option<NonNull<Node<T>>>,
}
Expand description
Roughly matches std::collections::linked_list::Cursor
.
Fields§
§preceding: Option<Preceding<NonNull<Node<T>>>>
The preceding element, mutably accessing this is unsafe.
current: Option<NonNull<Node<T>>>
The current element, mutably accessing this is unsafe.
root: &'a Option<NonNull<Node<T>>>
The current root element, mutably accessing this is unsafe.
succeeding_bound: Option<NonNull<Node<T>>>
self.current
can be equal to self.succeeding_bound
but it cannot be moved after this,
self.preceding
cannot be equal to self.succeeding_bound
.
Implementations§
Source§impl<'a, T> Cursor<'a, T>
impl<'a, T> Cursor<'a, T>
Sourcepub fn current(&self) -> Option<&T>
pub fn current(&self) -> Option<&T>
Get the current element.
Returns None
if the current element is None
or if the current element is the lower bound.
Sourcepub fn peek_move_preceding(&mut self) -> Option<&T>
pub fn peek_move_preceding(&mut self) -> Option<&T>
Moves the cursor to the preceding element returning a reference to the new element if one is present, otherwise returning None
.
Sourcepub fn move_preceding(&mut self) -> bool
pub fn move_preceding(&mut self) -> bool
Moves the cursor to the preceding element.
If there is no preceding element the cursor is not moved.
Sourcepub fn move_next(&mut self)
pub fn move_next(&mut self)
Moves the cursor to the next element if there is some current element and the next element is within the bounds of the cursor (when splitting a mutable cursor, an immutable cursor is produced where its bound restrict it to element above the mutable cursor).
Sourcepub fn move_child(&mut self)
pub fn move_child(&mut self)
Moves the cursor to the child element if there is some current element and the child element is within the bounds of the cursor (when splitting a mutable cursor, an immutable cursor is produced where its bound restrict it to element above the mutable cursor).
Sourcepub fn move_parent(&mut self) -> bool
pub fn move_parent(&mut self) -> bool
Moves the cursor through preceding elements until reaching a parent, if no parent is found, the cursor is reset to its original position.
Returns true
if the cursor was moved to a parent, or false
if not.
Sourcepub fn move_successor(&mut self) -> bool
pub fn move_successor(&mut self) -> bool
Moves the cursor to the successor element if one can be found. If there is no successor element the cursor is reset to its original position and is not moved.
Returns true
if the cursor was moved to a successor, or false
if not.
Sourcepub fn move_predecessor(&mut self) -> bool
pub fn move_predecessor(&mut self) -> bool
Moves the cursor to the predecessor element if one can be found. If there is no predecessor element the cursor is reset to its original position and is not moved.
Returns true
if the cursor was moved to a predecessor, or false
if not.
Sourcepub fn peek_parent(&self) -> Option<&T>
pub fn peek_parent(&self) -> Option<&T>
Returns a reference to the parent element.
Wrapper around self.peek_preceding().and_then(Preceding::parent)
.
Sourcepub fn peek_previous(&self) -> Option<&T>
pub fn peek_previous(&self) -> Option<&T>
Returns a reference to the previous element.
Wrapper around self.peek_preceding().and_then(Preceding::previous)
.
Sourcepub fn peek_preceding(&self) -> Option<Preceding<&T>>
pub fn peek_preceding(&self) -> Option<Preceding<&T>>
Returns a reference to the preceding element.
Sourcepub fn peek_child(&self) -> Option<&T>
pub fn peek_child(&self) -> Option<&T>
Returns a reference to the child element.