InitializedNode

Struct InitializedNode 

Source
pub struct InitializedNode<'node, T: ?Sized + Types> { /* private fields */ }
Expand description

A Node which is guaranteed to be initialized, accessed by Node::initialized and Node::initialized_mut.

You can never create and will never interact with owned or &mut instances of this type — it is accessed solely as &InitializedNode<'_, T> or Pin<&mut InitializedNode<'_, T>>.

Implementations§

Source§

impl<'node, T: ?Sized + Types> InitializedNode<'node, T>

Source

pub fn unprotected(&self) -> &T::Unprotected

Get a shared reference to the unprotected data of this node.

Source

pub fn protected<'list>( &self, list: &'list PinList<T>, ) -> Option<&'list T::Protected>

Get a shared reference to the protected data of this node.

Returns None if the node is in its removed state (has been removed from the list).

§Panics

Panics if the given list is a different one than this node was registered with.

Source

pub fn protected_mut<'list>( &self, list: &'list mut PinList<T>, ) -> Option<&'list mut T::Protected>

Get a unique reference to the protected data of this node.

Returns None if the node is in its removed state (has been removed from the list).

§Panics

Panics if the given list is a different one than this node was registered with.

Source

pub fn cursor<'list>(&self, list: &'list PinList<T>) -> Option<Cursor<'list, T>>

Obtain a shared cursor pointing to this node.

Returns None if the node was in its removed state (it was removed from the list).

§Panics

Panics if the given list is a different one than this node was registered with.

Source

pub fn cursor_mut<'list>( &self, list: &'list mut PinList<T>, ) -> Option<CursorMut<'list, T>>

Obtain a unique cursor pointing to this node.

Returns None if the node was in its removed state (it was removed from the list).

§Panics

Panics if the given list is a different one than this node was registered with.

Remove this node from its containing list and take its data, leaving the node in its initial state.

§Errors

Fails if the node is in its removed state — use take_removed to handle that case, or call reset instead.

§Panics

Panics if the given list is a different one than this node was registered with.

Source

pub fn take_removed( self: Pin<&'node mut Self>, list: &PinList<T>, ) -> Result<(T::Removed, T::Unprotected), Pin<&'node mut Self>>

Take the data out of this node if it has been removed from the list, leaving the node in its initial state.

§Errors

Errors if the node was in its “linked” state (it was still part of the list) — use unlink in this case, or call reset instead.

§Panics

Panics if the given list is a different one than this node was registered with.

Source

pub unsafe fn take_removed_unchecked( self: Pin<&'node mut Self>, ) -> (T::Removed, T::Unprotected)

Take the data out of this node, assuming that it has been removed from the list, leaving the node in its initial state.

In contrast to take_removed, this does not require access to the PinList.

§Safety

The node must not be in its linked state.

Source

pub fn reset( self: Pin<&'node mut Self>, list: &mut PinList<T>, ) -> (NodeData<T>, T::Unprotected)

Reset the node back to its initial state.

If the node is linked, this will unlink it, and then the node will be moved to the initial state.

This can be thought of as a combination of unlink and take_removed.

§Panics

Panics if the given list is a different one than this node was registered with.

Methods from Deref<Target = Node<T>>§

Source

pub fn is_initial(&self) -> bool

Check whether the node is in its initial state.

Source

pub fn insert_before( self: Pin<&mut Self>, cursor: &mut CursorMut<'_, T>, protected: T::Protected, unprotected: T::Unprotected, ) -> Pin<&mut InitializedNode<'_, T>>

Insert this node into the linked list before the given cursor.

§Panics

Panics if the node is not in its initial state.

Source

pub fn insert_after( self: Pin<&mut Self>, cursor: &mut CursorMut<'_, T>, protected: T::Protected, unprotected: T::Unprotected, ) -> Pin<&mut InitializedNode<'_, T>>

Insert this node into the linked list after the given cursor.

§Panics

Panics if the node is not in its initial state.

Source

pub fn initialized(&self) -> Option<&InitializedNode<'_, T>>

Borrow the node, if it is initialized (linked or removed).

Returns None if the node is in the initial state.

Source

pub fn initialized_mut( self: Pin<&mut Self>, ) -> Option<Pin<&mut InitializedNode<'_, T>>>

Borrow uniquely the node, if it is initialized (linked or removed).

Returns None if the node is in the initial state.

Trait Implementations§

Source§

impl<T: ?Sized + Types> Debug for InitializedNode<'_, T>
where T::Unprotected: Debug,

Source§

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

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

impl<T: ?Sized + Types> Deref for InitializedNode<'_, T>

Source§

type Target = Node<T>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<'node, T> !Freeze for InitializedNode<'node, T>

§

impl<'node, T> !RefUnwindSafe for InitializedNode<'node, T>

§

impl<'node, T> Send for InitializedNode<'node, T>
where <T as Types>::Id: Send, <T as Types>::Protected: Send, <T as Types>::Removed: Send, <T as Types>::Unprotected: Send + Sync, T: ?Sized,

§

impl<'node, T> Sync for InitializedNode<'node, T>
where <T as Types>::Id: Sync, <T as Types>::Unprotected: Sync, T: ?Sized,

§

impl<'node, T> !Unpin for InitializedNode<'node, T>

§

impl<'node, T> !UnwindSafe for InitializedNode<'node, T>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.