Skip to main content

Divisible

Trait Divisible 

Source
pub trait Divisible<T>: Sized {
    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 + '_;
    unsafe fn get_unchecked(&self, index: usize) -> T;
    unsafe fn set_unchecked(&mut self, index: usize, val: T);
    fn broadcast(val: T) -> Self;
    fn from_iter(iter: impl Iterator<Item = T>) -> Self;

    // Provided methods
    fn get(&self, index: usize) -> T { ... }
    fn set(&mut self, index: usize, val: T) { ... }
}
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§

Source

const LOG_N: usize

The log2 of the number of T elements that fit in Self.

Provided Associated Constants§

Source

const N: usize = _

The number of T elements that fit in Self.

Required Methods§

Source

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.

Source

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.

Source

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.

Source

unsafe fn get_unchecked(&self, index: usize) -> T

Get element at index (LSB-first ordering) without bounds checking.

§Safety

The caller must ensure that index < Self::N.

Source

unsafe fn set_unchecked(&mut self, index: usize, val: T)

Set element at index (LSB-first ordering) in place, without bounds checking.

§Safety

The caller must ensure that index < Self::N.

Source

fn broadcast(val: T) -> Self

Create a value with val broadcast to all N positions.

Source

fn from_iter(iter: impl Iterator<Item = T>) -> Self

Construct a value from an iterator of elements.

Consumes at most N elements from the iterator. If the iterator yields fewer than N elements, remaining positions are filled with zeros.

Provided Methods§

Source

fn get(&self, index: usize) -> T

Get element at index (LSB-first ordering).

§Panics

Panics if index >= Self::N.

Source

fn set(&mut self, index: usize, val: T)

Set element at index (LSB-first ordering), in place.

§Panics

Panics if index >= Self::N.

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.

Implementations on Foreign Types§

Source§

impl Divisible<u8> for u8

Source§

const LOG_N: usize = 0

Source§

fn value_iter(value: Self) -> impl ExactSizeIterator<Item = u8> + Send + Clone

Source§

fn ref_iter( value: &Self, ) -> impl ExactSizeIterator<Item = u8> + Send + Clone + '_

Source§

fn slice_iter( slice: &[Self], ) -> impl ExactSizeIterator<Item = u8> + Send + Clone + '_

Source§

unsafe fn get_unchecked(&self, _index: usize) -> u8

Source§

unsafe fn set_unchecked(&mut self, _index: usize, val: u8)

Source§

fn broadcast(val: u8) -> Self

Source§

fn from_iter(iter: impl Iterator<Item = u8>) -> Self

Source§

impl Divisible<u8> for u16

Source§

const LOG_N: usize

Source§

fn value_iter(value: Self) -> impl ExactSizeIterator<Item = u8> + Send + Clone

Source§

fn ref_iter( value: &Self, ) -> impl ExactSizeIterator<Item = u8> + Send + Clone + '_

Source§

fn slice_iter( slice: &[Self], ) -> impl ExactSizeIterator<Item = u8> + Send + Clone + '_

Source§

unsafe fn get_unchecked(&self, index: usize) -> u8

Source§

unsafe fn set_unchecked(&mut self, index: usize, val: u8)

Source§

fn broadcast(val: u8) -> Self

Source§

fn from_iter(iter: impl Iterator<Item = u8>) -> Self

Source§

impl Divisible<u8> for u32

Source§

const LOG_N: usize

Source§

fn value_iter(value: Self) -> impl ExactSizeIterator<Item = u8> + Send + Clone

Source§

fn ref_iter( value: &Self, ) -> impl ExactSizeIterator<Item = u8> + Send + Clone + '_

Source§

fn slice_iter( slice: &[Self], ) -> impl ExactSizeIterator<Item = u8> + Send + Clone + '_

Source§

unsafe fn get_unchecked(&self, index: usize) -> u8

Source§

unsafe fn set_unchecked(&mut self, index: usize, val: u8)

Source§

fn broadcast(val: u8) -> Self

Source§

fn from_iter(iter: impl Iterator<Item = u8>) -> Self

Source§

impl Divisible<u8> for u64

Source§

const LOG_N: usize

Source§

fn value_iter(value: Self) -> impl ExactSizeIterator<Item = u8> + Send + Clone

Source§

fn ref_iter( value: &Self, ) -> impl ExactSizeIterator<Item = u8> + Send + Clone + '_

Source§

fn slice_iter( slice: &[Self], ) -> impl ExactSizeIterator<Item = u8> + Send + Clone + '_

Source§

unsafe fn get_unchecked(&self, index: usize) -> u8

Source§

unsafe fn set_unchecked(&mut self, index: usize, val: u8)

Source§

fn broadcast(val: u8) -> Self

Source§

fn from_iter(iter: impl Iterator<Item = u8>) -> Self

Source§

impl Divisible<u8> for u128

Source§

const LOG_N: usize

Source§

fn value_iter(value: Self) -> impl ExactSizeIterator<Item = u8> + Send + Clone

Source§

fn ref_iter( value: &Self, ) -> impl ExactSizeIterator<Item = u8> + Send + Clone + '_

Source§

fn slice_iter( slice: &[Self], ) -> impl ExactSizeIterator<Item = u8> + Send + Clone + '_

Source§

unsafe fn get_unchecked(&self, index: usize) -> u8

Source§

unsafe fn set_unchecked(&mut self, index: usize, val: u8)

Source§

fn broadcast(val: u8) -> Self

Source§

fn from_iter(iter: impl Iterator<Item = u8>) -> Self

Source§

impl Divisible<u16> for u16

Source§

const LOG_N: usize = 0

Source§

fn value_iter(value: Self) -> impl ExactSizeIterator<Item = u16> + Send + Clone

Source§

fn ref_iter( value: &Self, ) -> impl ExactSizeIterator<Item = u16> + Send + Clone + '_

Source§

fn slice_iter( slice: &[Self], ) -> impl ExactSizeIterator<Item = u16> + Send + Clone + '_

Source§

unsafe fn get_unchecked(&self, _index: usize) -> u16

Source§

unsafe fn set_unchecked(&mut self, _index: usize, val: u16)

Source§

fn broadcast(val: u16) -> Self

Source§

fn from_iter(iter: impl Iterator<Item = u16>) -> Self

Source§

impl Divisible<u16> for u32

Source§

const LOG_N: usize

Source§

fn value_iter(value: Self) -> impl ExactSizeIterator<Item = u16> + Send + Clone

Source§

fn ref_iter( value: &Self, ) -> impl ExactSizeIterator<Item = u16> + Send + Clone + '_

Source§

fn slice_iter( slice: &[Self], ) -> impl ExactSizeIterator<Item = u16> + Send + Clone + '_

Source§

unsafe fn get_unchecked(&self, index: usize) -> u16

Source§

unsafe fn set_unchecked(&mut self, index: usize, val: u16)

Source§

fn broadcast(val: u16) -> Self

Source§

fn from_iter(iter: impl Iterator<Item = u16>) -> Self

Source§

impl Divisible<u16> for u64

Source§

const LOG_N: usize

Source§

fn value_iter(value: Self) -> impl ExactSizeIterator<Item = u16> + Send + Clone

Source§

fn ref_iter( value: &Self, ) -> impl ExactSizeIterator<Item = u16> + Send + Clone + '_

Source§

fn slice_iter( slice: &[Self], ) -> impl ExactSizeIterator<Item = u16> + Send + Clone + '_

Source§

unsafe fn get_unchecked(&self, index: usize) -> u16

Source§

unsafe fn set_unchecked(&mut self, index: usize, val: u16)

Source§

fn broadcast(val: u16) -> Self

Source§

fn from_iter(iter: impl Iterator<Item = u16>) -> Self

Source§

impl Divisible<u16> for u128

Source§

const LOG_N: usize

Source§

fn value_iter(value: Self) -> impl ExactSizeIterator<Item = u16> + Send + Clone

Source§

fn ref_iter( value: &Self, ) -> impl ExactSizeIterator<Item = u16> + Send + Clone + '_

Source§

fn slice_iter( slice: &[Self], ) -> impl ExactSizeIterator<Item = u16> + Send + Clone + '_

Source§

unsafe fn get_unchecked(&self, index: usize) -> u16

Source§

unsafe fn set_unchecked(&mut self, index: usize, val: u16)

Source§

fn broadcast(val: u16) -> Self

Source§

fn from_iter(iter: impl Iterator<Item = u16>) -> Self

Source§

impl Divisible<u32> for u32

Source§

const LOG_N: usize = 0

Source§

fn value_iter(value: Self) -> impl ExactSizeIterator<Item = u32> + Send + Clone

Source§

fn ref_iter( value: &Self, ) -> impl ExactSizeIterator<Item = u32> + Send + Clone + '_

Source§

fn slice_iter( slice: &[Self], ) -> impl ExactSizeIterator<Item = u32> + Send + Clone + '_

Source§

unsafe fn get_unchecked(&self, _index: usize) -> u32

Source§

unsafe fn set_unchecked(&mut self, _index: usize, val: u32)

Source§

fn broadcast(val: u32) -> Self

Source§

fn from_iter(iter: impl Iterator<Item = u32>) -> Self

Source§

impl Divisible<u32> for u64

Source§

const LOG_N: usize

Source§

fn value_iter(value: Self) -> impl ExactSizeIterator<Item = u32> + Send + Clone

Source§

fn ref_iter( value: &Self, ) -> impl ExactSizeIterator<Item = u32> + Send + Clone + '_

Source§

fn slice_iter( slice: &[Self], ) -> impl ExactSizeIterator<Item = u32> + Send + Clone + '_

Source§

unsafe fn get_unchecked(&self, index: usize) -> u32

Source§

unsafe fn set_unchecked(&mut self, index: usize, val: u32)

Source§

fn broadcast(val: u32) -> Self

Source§

fn from_iter(iter: impl Iterator<Item = u32>) -> Self

Source§

impl Divisible<u32> for u128

Source§

const LOG_N: usize

Source§

fn value_iter(value: Self) -> impl ExactSizeIterator<Item = u32> + Send + Clone

Source§

fn ref_iter( value: &Self, ) -> impl ExactSizeIterator<Item = u32> + Send + Clone + '_

Source§

fn slice_iter( slice: &[Self], ) -> impl ExactSizeIterator<Item = u32> + Send + Clone + '_

Source§

unsafe fn get_unchecked(&self, index: usize) -> u32

Source§

unsafe fn set_unchecked(&mut self, index: usize, val: u32)

Source§

fn broadcast(val: u32) -> Self

Source§

fn from_iter(iter: impl Iterator<Item = u32>) -> Self

Source§

impl Divisible<u64> for u64

Source§

const LOG_N: usize = 0

Source§

fn value_iter(value: Self) -> impl ExactSizeIterator<Item = u64> + Send + Clone

Source§

fn ref_iter( value: &Self, ) -> impl ExactSizeIterator<Item = u64> + Send + Clone + '_

Source§

fn slice_iter( slice: &[Self], ) -> impl ExactSizeIterator<Item = u64> + Send + Clone + '_

Source§

unsafe fn get_unchecked(&self, _index: usize) -> u64

Source§

unsafe fn set_unchecked(&mut self, _index: usize, val: u64)

Source§

fn broadcast(val: u64) -> Self

Source§

fn from_iter(iter: impl Iterator<Item = u64>) -> Self

Source§

impl Divisible<u64> for u128

Source§

const LOG_N: usize

Source§

fn value_iter(value: Self) -> impl ExactSizeIterator<Item = u64> + Send + Clone

Source§

fn ref_iter( value: &Self, ) -> impl ExactSizeIterator<Item = u64> + Send + Clone + '_

Source§

fn slice_iter( slice: &[Self], ) -> impl ExactSizeIterator<Item = u64> + Send + Clone + '_

Source§

unsafe fn get_unchecked(&self, index: usize) -> u64

Source§

unsafe fn set_unchecked(&mut self, index: usize, val: u64)

Source§

fn broadcast(val: u64) -> Self

Source§

fn from_iter(iter: impl Iterator<Item = u64>) -> Self

Source§

impl Divisible<u128> for u128

Source§

const LOG_N: usize = 0

Source§

fn value_iter(value: Self) -> impl ExactSizeIterator<Item = u128> + Send + Clone

Source§

fn ref_iter( value: &Self, ) -> impl ExactSizeIterator<Item = u128> + Send + Clone + '_

Source§

fn slice_iter( slice: &[Self], ) -> impl ExactSizeIterator<Item = u128> + Send + Clone + '_

Source§

unsafe fn get_unchecked(&self, _index: usize) -> u128

Source§

unsafe fn set_unchecked(&mut self, _index: usize, val: u128)

Source§

fn broadcast(val: u128) -> Self

Source§

fn from_iter(iter: impl Iterator<Item = u128>) -> Self

Implementors§

Source§

impl Divisible<u8> for binius_field::arch::portable::m128::M128

Source§

impl Divisible<u8> for binius_field::arch::M128

Source§

const LOG_N: usize = 4

Source§

impl Divisible<u16> for binius_field::arch::portable::m128::M128

Source§

impl Divisible<u16> for binius_field::arch::M128

Source§

const LOG_N: usize = 3

Source§

impl Divisible<u32> for binius_field::arch::portable::m128::M128

Source§

impl Divisible<u32> for binius_field::arch::M128

Source§

const LOG_N: usize = 2

Source§

impl Divisible<u64> for binius_field::arch::portable::m128::M128

Source§

impl Divisible<u64> for binius_field::arch::M128

Source§

const LOG_N: usize = 1

Source§

impl Divisible<u128> for binius_field::arch::portable::m128::M128

Source§

impl Divisible<u128> for binius_field::arch::M128

Source§

const LOG_N: usize = 0

Source§

impl Divisible<AESTowerField8b> for AESTowerField8b

Source§

const LOG_N: usize = 0

Source§

impl Divisible<M128> for binius_field::arch::portable::m128::M128

Source§

const LOG_N: usize = 0

Source§

impl Divisible<M128> for binius_field::arch::M128

Source§

const LOG_N: usize = 0

Source§

impl Divisible<BinaryField1b> for BinaryField1b

Source§

const LOG_N: usize = 0

Source§

impl Divisible<BinaryField128bGhash> for BinaryField128bGhash

Source§

const LOG_N: usize = 0

Source§

impl Divisible<GhashSq256b> for GhashSq256b

Source§

const LOG_N: usize = 0

Source§

impl<U, Scalar> Divisible<Scalar> for PackedPrimitiveType<U, Scalar>
where U: UnderlierType + Divisible<Scalar::Underlier>, Scalar: BinaryField,