#[repr(transparent)]pub struct NodePtr<N: Node>(NonNull<N>);
Expand description
A pointer to a Node
.
Tuple Fields§
§0: NonNull<N>
Implementations§
source§impl<N: Node> NodePtr<N>
impl<N: Node> NodePtr<N>
sourcepub fn allocate_node_ptr(node: N) -> Self
pub fn allocate_node_ptr(node: N) -> Self
Allocate the given Node
on the std::alloc::Global
heap and
return a NodePtr
that wrap the raw pointer.
sourcepub unsafe fn deallocate_node_ptr(node: Self) -> N
pub unsafe fn deallocate_node_ptr(node: Self) -> N
Deallocate a Node
object created with the
NodePtr::allocate_node_ptr
function.
Safety
- This function can only be called once for a given node object.
sourcepub unsafe fn replace(dest: Self, new_value: N) -> N
pub unsafe fn replace(dest: Self, new_value: N) -> N
Moves new_value
into the referenced dest
, returning the previous
dest
value.
Neither value is dropped.
Safety
- The node the
dest
pointers points to must not get accessed (read or written) through any other pointers concurrent to this modification.
sourcepub fn to_opaque(self) -> OpaqueNodePtr<N::Key, N::Value>
pub fn to_opaque(self) -> OpaqueNodePtr<N::Key, N::Value>
Cast node pointer back to an opaque version, losing type information
sourcepub fn read(self) -> ManuallyDrop<N>
pub fn read(self) -> ManuallyDrop<N>
Reads the Node from self without moving it. This leaves the memory in self unchanged.
sourcepub unsafe fn as_ref<'a>(self) -> &'a N
pub unsafe fn as_ref<'a>(self) -> &'a N
Returns a shared reference to the value.
Safety
- You must enforce Rust’s aliasing rules, since the returned lifetime ’a is arbitrarily chosen and does not necessarily reflect the actual lifetime of the data. In particular, for the duration of this lifetime, the memory the pointer points to must not get mutated (except inside UnsafeCell).
sourcepub unsafe fn as_mut<'a>(self) -> &'a mut N
pub unsafe fn as_mut<'a>(self) -> &'a mut N
Returns a unique mutable reference to the node.
Safety
- You must enforce Rust’s aliasing rules, since the returned lifetime ’a is arbitrarily chosen and does not necessarily reflect the actual lifetime of the node. In particular, for the duration of this lifetime, the node the pointer points to must not get accessed (read or written) through any other pointer.
source§impl<K, V> NodePtr<LeafNode<K, V>>
impl<K, V> NodePtr<LeafNode<K, V>>
sourcepub unsafe fn as_key_value_ref<'a>(self) -> (&'a K, &'a V)
pub unsafe fn as_key_value_ref<'a>(self) -> (&'a K, &'a V)
Returns a shared reference to the key and value of the pointed to
LeafNode
.
Safety
- You must enforce Rust’s aliasing rules, since the returned lifetime ’a is arbitrarily chosen and does not necessarily reflect the actual lifetime of the data. In particular, for the duration of this lifetime, the memory the pointer points to must not get mutated (except inside UnsafeCell).
sourcepub unsafe fn as_key_ref_value_mut<'a>(self) -> (&'a K, &'a mut V)
pub unsafe fn as_key_ref_value_mut<'a>(self) -> (&'a K, &'a mut V)
Returns a unique mutable reference to the key and value of the pointed
to LeafNode
.
Safety
- You must enforce Rust’s aliasing rules, since the returned lifetime ’a is arbitrarily chosen and does not necessarily reflect the actual lifetime of the node. In particular, for the duration of this lifetime, the node the pointer points to must not get accessed (read or written) through any other pointer.
sourcepub unsafe fn as_key_ref<'a>(self) -> &'a Kwhere
V: 'a,
pub unsafe fn as_key_ref<'a>(self) -> &'a Kwhere V: 'a,
Returns a unique mutable reference to the key and value of the pointed
to LeafNode
.
Safety
- You must enforce Rust’s aliasing rules, since the returned lifetime ’a is arbitrarily chosen and does not necessarily reflect the actual lifetime of the data. In particular, for the duration of this lifetime, the memory the pointer points to must not get mutated (except inside UnsafeCell).
sourcepub unsafe fn as_value_ref<'a>(self) -> &'a Vwhere
K: 'a,
V: 'a,
pub unsafe fn as_value_ref<'a>(self) -> &'a Vwhere K: 'a, V: 'a,
Returns a unique mutable reference to the key and value of the pointed
to LeafNode
.
Safety
- You must enforce Rust’s aliasing rules, since the returned lifetime ’a is arbitrarily chosen and does not necessarily reflect the actual lifetime of the data. In particular, for the duration of this lifetime, the memory the pointer points to must not get mutated (except inside UnsafeCell).
sourcepub unsafe fn as_value_mut<'a>(self) -> &'a mut Vwhere
K: 'a,
V: 'a,
pub unsafe fn as_value_mut<'a>(self) -> &'a mut Vwhere K: 'a, V: 'a,
Returns a unique mutable reference to the key and value of the pointed
to LeafNode
.
Safety
- You must enforce Rust’s aliasing rules, since the returned lifetime ’a is arbitrarily chosen and does not necessarily reflect the actual lifetime of the node. In particular, for the duration of this lifetime, the node the pointer points to must not get accessed (read or written) through any other pointer.