Struct pin_list::InitializedNode
source · [−]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
sourceimpl<'node, T: ?Sized + Types> InitializedNode<'node, T>
impl<'node, T: ?Sized + Types> InitializedNode<'node, T>
sourcepub fn unprotected(&self) -> &T::Unprotected
pub fn unprotected(&self) -> &T::Unprotected
Get a shared reference to the unprotected data of this node.
sourcepub fn protected_mut<'list>(
&self,
list: &'list mut PinList<T>
) -> Option<&'list mut T::Protected>
pub fn protected_mut<'list>(
&self,
list: &'list mut PinList<T>
) -> Option<&'list mut T::Protected>
sourcepub fn cursor_mut<'list>(
&self,
list: &'list mut PinList<T>
) -> Option<CursorMut<'list, T>>
pub fn cursor_mut<'list>(
&self,
list: &'list mut PinList<T>
) -> Option<CursorMut<'list, T>>
sourcepub fn unlink(
self: Pin<&'node mut Self>,
list: &mut PinList<T>
) -> Result<(T::Protected, T::Unprotected), Pin<&'node mut Self>>
pub fn unlink(
self: Pin<&'node mut Self>,
list: &mut PinList<T>
) -> Result<(T::Protected, T::Unprotected), Pin<&'node mut Self>>
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.
sourcepub fn take_removed(
self: Pin<&'node mut Self>,
list: &PinList<T>
) -> Result<(T::Removed, T::Unprotected), Pin<&'node mut Self>>
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.
sourcepub unsafe fn take_removed_unchecked(
self: Pin<&'node mut Self>
) -> (T::Removed, T::Unprotected)
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.
sourcepub fn reset(
self: Pin<&'node mut Self>,
list: &mut PinList<T>
) -> (NodeData<T>, T::Unprotected)
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>>
sourcepub fn is_initial(&self) -> bool
pub fn is_initial(&self) -> bool
Check whether the node is in its initial state.
sourcepub fn insert_before(
self: Pin<&mut Self>,
cursor: &mut CursorMut<'_, T>,
protected: T::Protected,
unprotected: T::Unprotected
) -> Pin<&mut InitializedNode<'_, T>>
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.
sourcepub fn insert_after(
self: Pin<&mut Self>,
cursor: &mut CursorMut<'_, T>,
protected: T::Protected,
unprotected: T::Unprotected
) -> Pin<&mut InitializedNode<'_, T>>
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.
sourcepub fn initialized(&self) -> Option<&InitializedNode<'_, T>>
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.
sourcepub fn initialized_mut(
self: Pin<&mut Self>
) -> Option<Pin<&mut InitializedNode<'_, T>>>
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
sourceimpl<T: ?Sized + Types> Debug for InitializedNode<'_, T> where
T::Unprotected: Debug,
impl<T: ?Sized + Types> Debug for InitializedNode<'_, T> where
T::Unprotected: Debug,
Auto Trait Implementations
impl<'node, T> !RefUnwindSafe for InitializedNode<'node, T>
impl<'node, T: ?Sized> 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,
impl<'node, T: ?Sized> Sync for InitializedNode<'node, T> where
<T as Types>::Id: Sync,
<T as Types>::Unprotected: Sync,
impl<'node, T> !Unpin for InitializedNode<'node, T>
impl<'node, T> !UnwindSafe for InitializedNode<'node, T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more