pub enum BitWidth {
Minimal,
PowerOfTwo,
Explicit(usize),
}
Expand description
Specifies the strategy for determining the number of bits for each integer.
This enum controls how the bit width of a FixedVec
is determined during
its construction. The choice of strategy involves a trade-off between memory
usage and random access performance.
§Performance Considerations
-
Minimal
vs.PowerOfTwo
: WhileMinimal
provides the most compact storage,PowerOfTwo
can offer better performance for certain operations. When thebit_width
is a power of two (e.g., 8, 16, 32) and aligns with word boundaries, some in-place operations likemap_in_place
can use a faster, word-at-a-time algorithm. -
Explicit
: This is the fastest strategy at construction time, as it avoids the need to iterate through the input data to find the maximum value. Use this when the required bit width is known in advance.
Variants§
Minimal
Use the minimum number of bits required to store the largest value.
This strategy analyzes the input data to find the maximum value and sets the bit width accordingly. It ensures the most compact memory representation.
PowerOfTwo
Round the bit width up to the next power of two (e.g., 8, 16, 32).
This strategy can improve random access performance for some in-place operations, as they can be implemented more efficiently with bit-shift operations on aligned data.
Explicit(usize)
Use a specific number of bits.
This strategy enforces a user-defined bit width. If any value in the input data exceeds what can be stored in this many bits, the build process will fail.
Trait Implementations§
impl Copy for BitWidth
impl Eq for BitWidth
impl StructuralPartialEq for BitWidth
Auto Trait Implementations§
impl Freeze for BitWidth
impl RefUnwindSafe for BitWidth
impl Send for BitWidth
impl Sync for BitWidth
impl Unpin for BitWidth
impl UnwindSafe for BitWidth
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DowncastableFrom<T> for T
impl<T> DowncastableFrom<T> for T
Source§fn downcast_from(value: T) -> T
fn downcast_from(value: T) -> T
Source§impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more