Struct blart::NodePtr

source ·
#[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>

source

pub unsafe fn new(ptr: *mut N) -> Self

Create a safe pointer to a Node.

Safety

Given pointer must be non-null, aligned, and valid for reads or writes of a value of N type.

source

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.

source

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

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

pub fn to_opaque(self) -> OpaqueNodePtr<N::Key, N::Value>

Cast node pointer back to an opaque version, losing type information

source

pub fn read(self) -> ManuallyDrop<N>

Reads the Node from self without moving it. This leaves the memory in self unchanged.

source

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).
source

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

pub fn to_ptr(self) -> *mut N

Acquires the underlying *mut pointer.

source§

impl<K, V> NodePtr<LeafNode<K, V>>

source

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).
source

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

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).
source

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).
source

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.

Trait Implementations§

source§

impl<N: Node> Clone for NodePtr<N>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<N: Node> Debug for NodePtr<N>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<N: Node> From<&mut N> for NodePtr<N>

source§

fn from(node_ref: &mut N) -> Self

Converts to this type from the input type.
source§

impl<N: Node> PartialEq<NodePtr<N>> for NodePtr<N>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<N: Node> Pointer for NodePtr<N>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter.
source§

impl<K, T, N: Node + Visitable<K, T>> Visitable<K, T> for NodePtr<N>

source§

fn super_visit_with<V: Visitor<K, T>>(&self, visitor: &mut V) -> V::Output

This function provides the default traversal behavior for the implementing type. Read more
source§

fn visit_with<V: Visitor<K, T>>(&self, visitor: &mut V) -> V::Output

This function will traverse the implementing type and execute any specific logic from the given Visitor. Read more
source§

impl<N: Node> Copy for NodePtr<N>

source§

impl<N: Node> Eq for NodePtr<N>

Auto Trait Implementations§

§

impl<N> RefUnwindSafe for NodePtr<N>where N: RefUnwindSafe,

§

impl<N> !Send for NodePtr<N>

§

impl<N> !Sync for NodePtr<N>

§

impl<N> Unpin for NodePtr<N>

§

impl<N> UnwindSafe for NodePtr<N>where N: RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.