pub trait ValidLength: Sealed + Default + Copy + TryFrom<usize> + Into<u32> {
    const ZERO: Self;
    const MAX: usize;

    // Required method
    fn to_usize(self) -> usize;

    // Provided method
    fn from_usize<T>(
        val: Box<[T]>
    ) -> Result<(Self, Box<[T]>), InvalidLength<T>> { ... }
}
Expand description

A sealed trait to represent valid lengths for a FixedArray.

This is implemented on u32 for non-16 bit platforms, and u16 on all platforms.

Required Associated Constants§

source

const ZERO: Self

source

const MAX: usize

Required Methods§

source

fn to_usize(self) -> usize

Provided Methods§

source

fn from_usize<T>(val: Box<[T]>) -> Result<(Self, Box<[T]>), InvalidLength<T>>

Errors

Errors if the val’s length cannot fit into Self.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl ValidLength for u8

source§

const ZERO: Self = 0u8

source§

const MAX: usize = 255usize

source§

fn to_usize(self) -> usize

source§

impl ValidLength for u16

source§

const ZERO: Self = 0u16

source§

const MAX: usize = 65_535usize

source§

fn to_usize(self) -> usize

source§

impl ValidLength for u32

source§

const ZERO: Self = 0u32

source§

const MAX: usize = 4_294_967_295usize

source§

fn to_usize(self) -> usize

Implementors§