SizeLessThan

Trait SizeLessThan 

Source
pub trait SizeLessThan<const SIZE: usize, const CHECK: bool>: SizeLessThan<SIZE, CHECK> { }
Expand description

Describes a type whose size is less than SIZE bytes.

§Examples

#![feature(generic_const_exprs)]
struct LessThan10Bytes<T: size_trait::SizeLessThan<10, true>>(T);
let _ = LessThan10Bytes([0u8; 5]);
#![feature(generic_const_exprs)]
struct NotLessThan2Bytes<T: size_trait::SizeLessThan<2, false>>(T);
let _ = NotLessThan2Bytes([0u8; 20]);

§Compilation Errors

#![feature(generic_const_exprs)]
struct LessThan10Bytes<T: size_trait::SizeLessThan<10, true>>(T);
let _ = LessThan10Bytes([0u8; 11]);
#![feature(generic_const_exprs)]
struct NotLessThan2Bytes<T: size_trait::SizeLessThan<2, false>>(T);
let _ = NotLessThan2Bytes(());
#![feature(generic_const_exprs)]
struct ElevenBytes([u8; 11]);
impl size_trait::SizeLessThan<10, true> for ElevenBytes {}
#![feature(generic_const_exprs)]
struct OneByte(u8);
impl size_trait::SizeLessThan<10, false> for OneByte {}

Implementors§

Source§

impl<const SIZE: usize, const CHECK: bool, T: SizeLessThan<SIZE, CHECK>> SizeLessThan<SIZE, CHECK> for T