pub trait NonZeroUnsigned: Unsigned + NonZero + Sealed { }
Expand description

Type-level non-zero unsigned integers.

§Examples

This trait is basically implemented for types that implement typenum’s Unsigned and NonZero.

use typerat::*;
use typenum::{UInt, UTerm};

fn to_u8_typenum<U: typenum::Unsigned + typenum::NonZero>() -> u8 {
    U::to_u8()
}

fn to_u8_typerat<U: NonZeroUnsigned>() -> u8 {
    U::to_u8()
}

assert_eq!(to_u8_typenum::<U1>(), 1_u8);
assert_eq!(to_u8_typerat::<U1>(), 1_u8);

Unlike typenum, compile time unsigned integers with leading zeros are not allowed.

assert_eq!(to_u8_typenum::<UInt<UTerm, B0>>(), 0_u8);
assert_eq!(to_u8_typerat::<UInt<UTerm, B0>>(), 0_u8);

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl NonZeroUnsigned for UInt<UTerm, B1>

source§

impl<U, B> NonZeroUnsigned for UInt<U, B>
where U: NonZeroUnsigned, B: Bit,

Implementors§