Trait ToBits

Source
pub trait ToBits {
    // Required method
    fn to_bits<const N: usize>(self) -> Bits<N>;
}
Expand description

The ToBits trait is used to provide a way to convert Rust standard unsigned types (currently u8, u16, u32, u64, u128) into Bits of different lengths. Note that RustHDL will panic if you attempt to convert an unsigned type into a Bits that is too small to hold the value.

Required Methods§

Source

fn to_bits<const N: usize>(self) -> Bits<N>

Convert the underlying type to a Bits of the specified size. Invoked using

let x : Bits<4> = 0xF_u8.to_bits();

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 ToBits for u8

Source§

fn to_bits<const N: usize>(self) -> Bits<N>

Source§

impl ToBits for u16

Source§

fn to_bits<const N: usize>(self) -> Bits<N>

Source§

impl ToBits for u32

Source§

fn to_bits<const N: usize>(self) -> Bits<N>

Source§

impl ToBits for u64

Source§

fn to_bits<const N: usize>(self) -> Bits<N>

Source§

impl ToBits for u128

Source§

fn to_bits<const N: usize>(self) -> Bits<N>

Source§

impl ToBits for usize

Source§

fn to_bits<const N: usize>(self) -> Bits<N>

Implementors§