Sbits

Trait Sbits 

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

The Sbit trait for define the size of integer value in bits.

§Usage

Basic use of the trait.

use num_convert::Sbits;

assert_eq!(127_i8.sbits(), 8_u32);
assert_eq!(0_u64.sbits(), 64_u32);

§Examples

fn get_bits_from_value<T: Sbits>(value: T) -> u32 {
    value.sbits()
}

assert_eq!(get_bits_from_value(65_535_u16), 16_u32);
assert_eq!(get_bits_from_value(u128::MAX), 128_u32);

Required Methods§

Source

fn sbits(&self) -> u32

Method returns the size of integers value in bits.

Implementations on Foreign Types§

Source§

impl Sbits for i8

Source§

fn sbits(&self) -> u32

The size of i8 integer value in bits.

Source§

impl Sbits for i16

Source§

fn sbits(&self) -> u32

The size of i16 integer value in bits.

Source§

impl Sbits for i32

Source§

fn sbits(&self) -> u32

The size of i32 integer value in bits.

Source§

impl Sbits for i64

Source§

fn sbits(&self) -> u32

The size of i64 integer value in bits.

Source§

impl Sbits for i128

Source§

fn sbits(&self) -> u32

The size of i128 integer value in bits.

Source§

impl Sbits for isize

Source§

fn sbits(&self) -> u32

The size of isize integer value in bits.

Source§

impl Sbits for u8

Source§

fn sbits(&self) -> u32

The size of u8 integer value in bits.

Source§

impl Sbits for u16

Source§

fn sbits(&self) -> u32

The size of u16 integer value in bits.

Source§

impl Sbits for u32

Source§

fn sbits(&self) -> u32

The size of u32 integer value in bits.

Source§

impl Sbits for u64

Source§

fn sbits(&self) -> u32

The size of u64 integer value in bits.

Source§

impl Sbits for u128

Source§

fn sbits(&self) -> u32

The size of u128 integer value in bits.

Source§

impl Sbits for usize

Source§

fn sbits(&self) -> u32

The size of usize integer value in bits.

Implementors§