Skip to main content

Divisible

Trait Divisible 

Source
pub unsafe trait Divisible<Narrow: Underlier>: Underlier {
    const RATIO: usize = _;
    const CHECK_LAYOUT: () = _;

    // Provided methods
    fn parts(&self) -> &[Narrow] { ... }
    fn parts_mut(&mut self) -> &mut [Narrow] { ... }
    fn split_slice(slice: &[Self]) -> &[Narrow] { ... }
    fn split_slice_mut(slice: &mut [Self]) -> &mut [Narrow] { ... }
}
Expand description

A block that is exactly several narrower blocks laid end to end, part 0 lowest.

§Safety

The trait is sealed, and every implementation is checked below at compile time:

  • the wide size is the ratio times the narrow size,
  • the wide alignment is at least the narrow alignment,
  • the target is little-endian whenever the narrow word is the shorter one.

The three together are what make the reinterpretations sound.

Provided Associated Constants§

Source

const RATIO: usize = _

How many narrow blocks fit in one wide block.

Source

const CHECK_LAYOUT: () = _

What every reinterpretation above rests on, rejected at compile time if it fails.

Reading a block at a narrower word is a memory-order view. A lane is defined on word values, so the two agree only on a little-endian target.

Views that keep the word width are pure reindexing, and hold either way.

Provided Methods§

Source

fn parts(&self) -> &[Narrow]

The narrow blocks this one is made of, lowest bits first.

Source

fn parts_mut(&mut self) -> &mut [Narrow]

The narrow blocks this one is made of, lowest bits first.

Source

fn split_slice(slice: &[Self]) -> &[Narrow]

A run of wide blocks read as one run of narrow ones, lowest bits first.

Source

fn split_slice_mut(slice: &mut [Self]) -> &mut [Narrow]

A run of wide blocks read as one run of narrow ones, lowest bits first.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Divisible<u8> for u16

Source§

impl Divisible<u8> for u32

Source§

impl Divisible<u8> for u64

Source§

impl Divisible<u16> for u32

Source§

impl Divisible<u16> for u64

Source§

impl Divisible<u32> for u64

Implementors§