Skip to main content

Dllink

Struct Dllink 

Source
pub struct Dllink<T> {
    pub next: *mut Dllink<T>,
    pub prev: *mut Dllink<T>,
    pub data: T,
    /* private fields */
}
Expand description

A doubly-linked list node.

Each node holds a value of type T and pointers to the next and previous nodes in the list. A freshly created node is “locked” (points to itself), acting as a sentinel. Call lock() / is_locked() to manage this state.

§Safety

This type uses raw pointers internally and is neither Send nor Sync. The caller must ensure that all nodes outlive any pointers referencing them.

Fields§

§next: *mut Dllink<T>

Pointer to the next node.

§prev: *mut Dllink<T>

Pointer to the previous node.

§data: T

Stored data value.

Implementations§

Source§

impl<T> Dllink<T>

Source

pub const fn new(data: T) -> Self

Creates a new locked (detached) Dllink with the given data.

A locked node has null pointers and is not part of any list. Use new_linked for an alias, or manually set next/prev to link the node into a list.

Source

pub fn new_linked(data: T) -> Self

Creates a new locked (detached) Dllink.

Source

pub fn lock(&mut self)

Locks the node (nulls pointers). After locking, the node is not part of any list.

Source

pub fn is_locked(&self) -> bool

Returns true if the node is locked (null pointers, not in a list).

Source

pub fn detach(&mut self)

Detaches this node from its containing list.

Panics if the node is locked (not in a list).

Auto Trait Implementations§

§

impl<T> !Send for Dllink<T>

§

impl<T> !Sync for Dllink<T>

§

impl<T> Freeze for Dllink<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Dllink<T>
where T: RefUnwindSafe,

§

impl<T> Unpin for Dllink<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Dllink<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Dllink<T>

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