Skip to main content

PathComponent

Struct PathComponent 

Source
pub struct PathComponent(pub U4);
Expand description

A path component in a hexary trie; which is only 4 bits (aka a nibble).

Tuple Fields§

§0: U4

Implementations§

Source§

impl PathComponent

Source

pub const ALL: [Self; 16]

All possible path components.

This makes it easy to iterate over all possible children of a branch in a type-safe way. It is preferrable to do:

for (idx, slot) in PathComponent::ALL.into_iter().zip(branch.children.each_ref()) {
    /// use idx and slot
}

instead of using a raw range like (0..16) or Iterator::enumerate, which does not give a type-safe path component.

Source

pub const LEN: usize = 16

The number of possible path components.

Source§

impl PathComponent

Source

pub const fn as_u8(self) -> u8

Returns the path component as a u8.

Source

pub const fn as_usize(self) -> usize

Returns the path component as a usize.

Source

pub const fn try_new(value: u8) -> Option<Self>

Tries to create a path component from the given u8.

For hexary tries, the input must be in the range 0x00 to 0x0F inclusive. Any value outside this range will result in None.

For 256-ary tries, any value is valid.

Source

pub const fn new_pair(v: u8) -> (Self, Self)

Creates a pair of path components from a single byte where the upper 4 bits are the first component and the lower 4 bits are the second component.

Source

pub const fn join(self, other: Self) -> u8

Joins this PathComponent with another to create a single u8 where this component is the upper 4 bits and the provided component is the lower 4 bits.

Trait Implementations§

Source§

impl Binary for PathComponent

Source§

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

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

impl Clone for PathComponent

Source§

fn clone(&self) -> PathComponent

Returns a duplicate 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 Debug for PathComponent

Source§

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

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

impl Display for PathComponent

Source§

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

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

impl Extend<PathComponent> for PathGuard<'_>

Source§

fn extend<T: IntoIterator<Item = PathComponent>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl Hash for PathComponent

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T> Index<PathComponent> for Children<T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: PathComponent) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> IndexMut<PathComponent> for Children<T>

Source§

fn index_mut(&mut self, index: PathComponent) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl LowerHex for PathComponent

Source§

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

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

impl Ord for PathComponent

Source§

fn cmp(&self, other: &PathComponent) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for PathComponent

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for PathComponent

Source§

fn partial_cmp(&self, other: &PathComponent) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl TriePath for PathComponent

Source§

type Components<'a> = IntoIter<PathComponent> where Self: 'a

The iterator returned by TriePath::components.
Source§

fn len(&self) -> usize

The length, in path components, of this path.
Source§

fn components(&self) -> Self::Components<'_>

Returns an iterator over the components of this path.
Source§

fn as_component_slice(&self) -> PartialPath<'_>

Returns a contiguous view of this path’s components. Read more
Source§

fn is_empty(&self) -> bool

Returns true if this path is empty (i.e. has length 0).
Source§

fn append<S>(self, suffix: S) -> JoinedPath<Self, S>
where Self: Sized, S: TriePath,

Appends the provided path segment to this path, returning a new joined path that represents the concatenation of the two paths. Read more
Source§

fn prepend<P>(self, prefix: P) -> JoinedPath<P, Self>
where Self: Sized, P: TriePath,

Prepends the provided path segment to this path, returning a new joined path that represents the concatenation of the two paths. Read more
Source§

fn path_eq<T: TriePath + ?Sized>(&self, other: &T) -> bool

Compares this path against another path for equality using path component equality. Read more
Source§

fn path_cmp<T: TriePath + ?Sized>(&self, other: &T) -> Ordering

Compares this path against another path using path-component lexicographic ordering. Strict prefixes are less than their longer counterparts. Read more
Source§

fn display(&self) -> DisplayPath<'_, Self>

Returns a wrapper type that implements std::fmt::Display and std::fmt::Debug for this path.
Source§

impl UpperHex for PathComponent

Source§

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

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

impl Copy for PathComponent

Source§

impl Eq for PathComponent

Source§

impl StructuralPartialEq for PathComponent

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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 T
where 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> TriePathAsPackedBytes for T
where T: TriePath + ?Sized,

Source§

type PackedBytesIter<'a> = PackedBytes<<T as TriePath>::Components<'a>> where T: 'a

The iterator type returned by TriePathAsPackedBytes::as_packed_bytes.
Source§

fn as_packed_bytes(&self) -> <T as TriePathAsPackedBytes>::PackedBytesIter<'_>

Returns an iterator over the packed bytes of this path. Read more
Source§

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

Source§

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

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ValueSize for T

Source§

fn value_size(&self) -> usize

The size of this value in bytes, excluding allocated data. Read more
Source§

fn value_size_sum_iter<'item>(iterator: impl Iterator<Item = &'item T>) -> usize
where T: 'item,

The total sum of the sizes of all values in the given iterator, in bytes. This is default-implemented by computing ValueSize::value_size on every element and summing them. For Sized types, a more potentially efficient implementation using Iterator::count is provided. If you are implementing this trait manually, it is unlikely to be more efficient to provide a manual implementation here. Read more
Source§

fn value_size_sum_exact_size_iter<'item>( iterator: impl ExactSizeIterator<Item = &'item T>, ) -> usize
where T: 'item,

The total sum of the sizes of all values in the given exact-size-iterator, in bytes. This is default-implemented by using ValueSize::value_size_sum_iter. For Sized types, a usually more efficient implementation using ExactSizeIterator::len is provided. If you are implementing this trait manually, it is unlikely to be more efficient to provide a manual implementation here. Read more