NodeRef

Trait NodeRef 

Source
unsafe trait NodeRef: Copy {
    type Value;

    // Required methods
    unsafe fn range(self, is_leaf: bool) -> Range<i32> ;
    unsafe fn child(self, idx: i32) -> Option<Self>;
    unsafe fn value(self, idx: i32) -> Option<Self::Value>;
}
Expand description

Abstraction over shared (&Node<V>) and exclusive (*mut Node<V>) node access.

This trait allows KdIterator to be generic over the borrowing mode, so a single iterator implementation drives both iter (shared) and iter_mut (exclusive).

§Safety

Implementations must ensure that:

  • range, child, and value uphold the safety preconditions of the underlying Node methods (i.e. leaf methods are only called on leaf nodes, and inner methods on inner nodes).
  • For mutable implementations, the returned value references do not alias.

Required Associated Types§

Required Methods§

Source

unsafe fn range(self, is_leaf: bool) -> Range<i32>

Returns the range of indices for this node.

§Safety

is_leaf must correctly indicate whether this is a leaf node.

Source

unsafe fn child(self, idx: i32) -> Option<Self>

Returns a handle to the child node at idx, or None if no child exists.

§Safety

Must only be called on inner nodes.

Source

unsafe fn value(self, idx: i32) -> Option<Self::Value>

Returns a reference to the value at idx, or None if the slot is empty.

§Safety

Must only be called on leaf nodes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a, V> NodeRef for &'a Node<V>

Shared node reference. Yields &V values.

Source§

impl<'a, V> NodeRef for NodePtrMut<'a, V>

Exclusive node reference. Yields &mut V values.