Struct Cursor

Source
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

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>

Source

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.

Source

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.

Source

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.

Source

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).

Source

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).

Source

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.

Source

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.

Source

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.

Source

pub fn peek_next(&self) -> Option<&T>

Returns a reference to the next element.

Source

pub fn peek_parent(&self) -> Option<&T>

Returns a reference to the parent element.

Wrapper around self.peek_preceding().and_then(Preceding::parent).

Source

pub fn peek_previous(&self) -> Option<&T>

Returns a reference to the previous element.

Wrapper around self.peek_preceding().and_then(Preceding::previous) .

Source

pub fn peek_preceding(&self) -> Option<Preceding<&T>>

Returns a reference to the preceding element.

Source

pub fn peek_child(&self) -> Option<&T>

Returns a reference to the child element.

Trait Implementations§

Source§

impl<'a, T> Clone for Cursor<'a, T>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, T: Debug> Debug for Cursor<'a, T>

Source§

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

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

impl<'a, T> From<RestrictedCursor<'a, T>> for Cursor<'a, T>

Source§

fn from(cursor: RestrictedCursor<'a, T>) -> Cursor<'a, T>

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a, T> Freeze for Cursor<'a, T>

§

impl<'a, T> RefUnwindSafe for Cursor<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> !Send for Cursor<'a, T>

§

impl<'a, T> !Sync for Cursor<'a, T>

§

impl<'a, T> Unpin for Cursor<'a, T>

§

impl<'a, T> UnwindSafe for Cursor<'a, T>
where T: RefUnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.