Struct Node

Source
pub struct Node<V>
where V: Variant,
{ /* private fields */ }
Expand description

Node of the self referential collection.

Implementations§

Source§

impl<V> Node<V>
where V: Variant,

Source

pub fn new_active(data: V::Item, prev: V::Prev, next: V::Next) -> Self

Creates a new active node with the given data, and prev and next references.

Source

pub fn new_free_node(data: V::Item) -> Self

Creates a new active node with the given data but with no connections.

Source

pub fn into_data(self) -> Option<V::Item>

Takes and returns the data of the node, transitions the node into the closed state.

Source

pub fn data(&self) -> Option<&V::Item>

Returns a reference to the data of the node; None if the node is already closed.

Source

pub fn prev(&self) -> &V::Prev

Returns a reference to the previous references.

Source

pub fn next(&self) -> &V::Next

Returns a reference to the next references.

Source

pub fn is_active(&self) -> bool

Returns true if the node is active, false if it is closed.

Source

pub fn is_closed(&self) -> bool

Returns true if the node is closed, false if it is active.

Source

pub fn data_mut(&mut self) -> Option<&mut V::Item>

Returns a mutable reference to the underlying data.

Source

pub fn prev_mut(&mut self) -> &mut V::Prev

Returns a mutable reference to the previous references.

Source

pub fn next_mut(&mut self) -> &mut V::Next

Returns a mutable reference to the next references.

Source

pub fn close(&mut self) -> V::Item

Closes the node and returns its data, and clears its connections.

§Panics

Panics if the node was already closed.

Source

pub fn swap_data(&mut self, new_value: V::Item) -> V::Item

Swaps the data of the node with the new_value and returns the old value.

§Panics

Panics if the node was already closed.

Source

pub fn take_data(&mut self) -> Option<V::Item>

Closes the node and returns its data.

§Panics

Panics if the node was already closed.

Trait Implementations§

Source§

impl<V: Variant> Debug for Node<V>
where V::Item: Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<V> Freeze for Node<V>
where <V as Variant>::Prev: Freeze, <V as Variant>::Next: Freeze, <V as Variant>::Item: Freeze,

§

impl<V> RefUnwindSafe for Node<V>

§

impl<V> Send for Node<V>
where <V as Variant>::Prev: Send, <V as Variant>::Next: Send, <V as Variant>::Item: Send,

§

impl<V> Sync for Node<V>
where <V as Variant>::Prev: Sync, <V as Variant>::Next: Sync, <V as Variant>::Item: Sync,

§

impl<V> Unpin for Node<V>
where <V as Variant>::Prev: Unpin, <V as Variant>::Next: Unpin, <V as Variant>::Item: Unpin,

§

impl<V> UnwindSafe for Node<V>
where <V as Variant>::Prev: UnwindSafe, <V as Variant>::Next: UnwindSafe, <V as Variant>::Item: UnwindSafe,

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> 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> SoM<T> for T

Source§

fn get_ref(&self) -> &T

Returns a reference to self.
Source§

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

Returns a mutable reference to self.
Source§

impl<T> SoR<T> for T

Source§

fn get_ref(&self) -> &T

Returns a reference to self.
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.