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: TStored data value.
Implementations§
Source§impl<T> Dllink<T>
impl<T> Dllink<T>
Sourcepub const fn new(data: T) -> Self
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.
Sourcepub fn new_linked(data: T) -> Self
pub fn new_linked(data: T) -> Self
Creates a new locked (detached) Dllink.
Sourcepub fn lock(&mut self)
pub fn lock(&mut self)
Locks the node (nulls pointers). After locking, the node is not part of any list.