pub trait Divisible<T>: Copy {
const LOG_N: usize;
const N: usize = _;
// Required methods
fn value_iter(
value: Self,
) -> impl ExactSizeIterator<Item = T> + Send + Clone;
fn ref_iter(
value: &Self,
) -> impl ExactSizeIterator<Item = T> + Send + Clone + '_;
fn slice_iter(
slice: &[Self],
) -> impl ExactSizeIterator<Item = T> + Send + Clone + '_;
fn get(self, index: usize) -> T;
fn set(self, index: usize, val: T) -> Self;
}Expand description
Divides an underlier type into smaller underliers in memory and iterates over them.
Divisible provides iteration over the subdivisions of an underlier type, guaranteeing that
iteration proceeds from the least significant bits to the most significant bits, regardless of
the CPU architecture’s endianness.
§Endianness Handling
To ensure consistent LSB-to-MSB iteration order across all platforms:
- On little-endian systems: elements are naturally ordered LSB-to-MSB in memory, so iteration proceeds forward through the array
- On big-endian systems: elements are ordered MSB-to-LSB in memory, so iteration is reversed to achieve LSB-to-MSB order
This abstraction allows code to work with subdivided underliers in a platform-independent way while maintaining the invariant that the first element always represents the least significant portion of the value.
Required Associated Constants§
Provided Associated Constants§
Required Methods§
Sourcefn value_iter(value: Self) -> impl ExactSizeIterator<Item = T> + Send + Clone
fn value_iter(value: Self) -> impl ExactSizeIterator<Item = T> + Send + Clone
Returns an iterator over subdivisions of this underlier value, ordered from LSB to MSB.
Sourcefn ref_iter(
value: &Self,
) -> impl ExactSizeIterator<Item = T> + Send + Clone + '_
fn ref_iter( value: &Self, ) -> impl ExactSizeIterator<Item = T> + Send + Clone + '_
Returns an iterator over subdivisions of this underlier reference, ordered from LSB to MSB.
Sourcefn slice_iter(
slice: &[Self],
) -> impl ExactSizeIterator<Item = T> + Send + Clone + '_
fn slice_iter( slice: &[Self], ) -> impl ExactSizeIterator<Item = T> + Send + Clone + '_
Returns an iterator over subdivisions of a slice of underliers, ordered from LSB to MSB.
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.