pub trait DoublyPointer<T> {
// Required method
unsafe fn raw_ptr(&self) -> *mut Node<Doubly<T>>;
// Provided methods
unsafe fn node(&self) -> &Node<Doubly<T>> { ... }
unsafe fn node_mut(&mut self) -> &mut Node<Doubly<T>> { ... }
unsafe fn next(&self) -> Option<DoublyPtr<T>> { ... }
unsafe fn prev(&self) -> Option<DoublyPtr<T>> { ... }
}Expand description
A node pointer in a doubly linked list.
Required Methods§
Sourceunsafe fn raw_ptr(&self) -> *mut Node<Doubly<T>>
unsafe fn raw_ptr(&self) -> *mut Node<Doubly<T>>
Returns the raw pointer to the node.
§SAFETY
This method is unsafe as node pointers implement Send and Sync.
It is safe dereference the received pointer if we know that is_valid_for(col) would
return true where col is the collection that this pointer is created from.
Provided Methods§
Sourceunsafe fn node(&self) -> &Node<Doubly<T>>
unsafe fn node(&self) -> &Node<Doubly<T>>
Returns a reference to the node.
§Safety
This method creates a reference directly from the pointer without any checks.
The caller is responsible for the validness of the node pointer.
Alternatively, you may use NodeIdx for safe access.
Sourceunsafe fn node_mut(&mut self) -> &mut Node<Doubly<T>>
unsafe fn node_mut(&mut self) -> &mut Node<Doubly<T>>
Returns a mutable reference to the node.
§Safety
This method creates a reference directly from the pointer without any checks.
The caller is responsible for the validness of the node pointer.
Alternatively, you may use NodeIdx for safe access.
Sourceunsafe fn next(&self) -> Option<DoublyPtr<T>>
unsafe fn next(&self) -> Option<DoublyPtr<T>>
Returns the pointer to the next node if exists; None otherwise.
§Safety
This method creates a reference directly from the pointer without any checks.
The caller is responsible for the validness of the node pointer.
Alternatively, you may use NodeIdx for safe access.
Sourceunsafe fn prev(&self) -> Option<DoublyPtr<T>>
unsafe fn prev(&self) -> Option<DoublyPtr<T>>
Returns the pointer to the prev node if exists; None otherwise.
§Safety
This method creates a reference directly from the pointer without any checks.
The caller is responsible for the validness of the node pointer.
Alternatively, you may use NodeIdx for safe access.