Tbits

Trait Tbits 

Source
pub trait Tbits {
    // Required method
    fn tbits() -> u32;
}
Available on crate feature bits only.
Expand description

Generic trait for define the size of the integers type in bits.

§Usage

Basic use of the trait.

use num_convert::Tbits;

assert_eq!(i8::tbits(), 8_u32);
assert_eq!(u64::tbits(), 64_u32);

§Examples

fn get_bits_from_type<T: Tbits>(value: T) -> u32 {
    T::tbits()
}

assert_eq!(get_bits_from_type(-128_i8), 8_u32);
assert_eq!(get_bits_from_type(isize::MIN), 64_u32);

Required Methods§

Source

fn tbits() -> u32

Returns the size of integer type in 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 Tbits for i8

Source§

fn tbits() -> u32

The size of i8 integer type in bits.

Source§

impl Tbits for i16

Source§

fn tbits() -> u32

The size of i16 integer type in bits.

Source§

impl Tbits for i32

Source§

fn tbits() -> u32

The size of i32 integer type in bits.

Source§

impl Tbits for i64

Source§

fn tbits() -> u32

The size of i64 integer type in bits.

Source§

impl Tbits for i128

Source§

fn tbits() -> u32

The size of i128 integer type in bits.

Source§

impl Tbits for isize

Source§

fn tbits() -> u32

The size of isize integer type in bits.

Source§

impl Tbits for u8

Source§

fn tbits() -> u32

The size of u8 integer type in bits.

Source§

impl Tbits for u16

Source§

fn tbits() -> u32

The size of u16 integer type in bits.

Source§

impl Tbits for u32

Source§

fn tbits() -> u32

The size of u32 integer type in bits.

Source§

impl Tbits for u64

Source§

fn tbits() -> u32

The size of u64 integer type in bits.

Source§

impl Tbits for u128

Source§

fn tbits() -> u32

The size of u128 integer type in bits.

Source§

impl Tbits for usize

Source§

fn tbits() -> u32

The size of usize integer type in bits.

Implementors§