BaseOps

Trait BaseOps 

Source
pub trait BaseOps: Copy {
    type U;

    const NUMBITS: u8;
    const MINVAL: Self;
    const MAXVAL: Self;

    // Required methods
    fn from_u8(v: u8) -> Self;
    fn from_unsigned(v: Wrapping<Self::U>) -> Self;
    fn to_unsigned(&self) -> Wrapping<Self::U>;
    fn fls(&self) -> u8;
}
Expand description

Internal trait for basic operations on the output type.

Required Associated Constants§

Source

const NUMBITS: u8

Number of bits in type Self.

Source

const MINVAL: Self

Smallest possible value of type Self.

Source

const MAXVAL: Self

Biggest possible value of type Self.

Required Associated Types§

Source

type U

Unsigned companion of Self.

Required Methods§

Source

fn from_u8(v: u8) -> Self

Convert an u8 to Self.

Source

fn from_unsigned(v: Wrapping<Self::U>) -> Self

Convert a wrapping unsigned to a bit identical Self.

Source

fn to_unsigned(&self) -> Wrapping<Self::U>

Convert self to a bit identical wrapping unsigned.

Source

fn fls(&self) -> u8

Find last bit set in self.

Bit 0 -> returns 1; Bit 1 -> returns 2; …

If no bit set -> returns 0.

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 BaseOps for i8

Source§

const NUMBITS: u8 = 8u8

Source§

const MINVAL: i8 = -128i8

Source§

const MAXVAL: i8 = 127i8

Source§

type U = u8

Source§

fn from_u8(v: u8) -> i8

Source§

fn from_unsigned(v: Wrapping<Self::U>) -> Self

Source§

fn to_unsigned(&self) -> Wrapping<Self::U>

Source§

fn fls(&self) -> u8

Source§

impl BaseOps for i16

Source§

const NUMBITS: u8 = 16u8

Source§

const MINVAL: i16 = -32_768i16

Source§

const MAXVAL: i16 = 32_767i16

Source§

type U = u16

Source§

fn from_u8(v: u8) -> i16

Source§

fn from_unsigned(v: Wrapping<Self::U>) -> Self

Source§

fn to_unsigned(&self) -> Wrapping<Self::U>

Source§

fn fls(&self) -> u8

Source§

impl BaseOps for i32

Source§

const NUMBITS: u8 = 32u8

Source§

const MINVAL: i32 = -2_147_483_648i32

Source§

const MAXVAL: i32 = 2_147_483_647i32

Source§

type U = u32

Source§

fn from_u8(v: u8) -> i32

Source§

fn from_unsigned(v: Wrapping<Self::U>) -> Self

Source§

fn to_unsigned(&self) -> Wrapping<Self::U>

Source§

fn fls(&self) -> u8

Source§

impl BaseOps for i64

Source§

const NUMBITS: u8 = 64u8

Source§

const MINVAL: i64 = -9_223_372_036_854_775_808i64

Source§

const MAXVAL: i64 = 9_223_372_036_854_775_807i64

Source§

type U = u64

Source§

fn from_u8(v: u8) -> i64

Source§

fn from_unsigned(v: Wrapping<Self::U>) -> Self

Source§

fn to_unsigned(&self) -> Wrapping<Self::U>

Source§

fn fls(&self) -> u8

Source§

impl BaseOps for i128

Source§

const NUMBITS: u8 = 128u8

Source§

const MINVAL: i128 = -170_141_183_460_469_231_731_687_303_715_884_105_728i128

Source§

const MAXVAL: i128 = 170_141_183_460_469_231_731_687_303_715_884_105_727i128

Source§

type U = u128

Source§

fn from_u8(v: u8) -> i128

Source§

fn from_unsigned(v: Wrapping<Self::U>) -> Self

Source§

fn to_unsigned(&self) -> Wrapping<Self::U>

Source§

fn fls(&self) -> u8

Source§

impl BaseOps for isize

Source§

const NUMBITS: u8 = 64u8

Source§

const MINVAL: isize = -9_223_372_036_854_775_808isize

Source§

const MAXVAL: isize = 9_223_372_036_854_775_807isize

Source§

type U = usize

Source§

fn from_u8(v: u8) -> isize

Source§

fn from_unsigned(v: Wrapping<Self::U>) -> Self

Source§

fn to_unsigned(&self) -> Wrapping<Self::U>

Source§

fn fls(&self) -> u8

Source§

impl BaseOps for u8

Source§

const NUMBITS: u8 = 8u8

Source§

const MINVAL: u8 = 0u8

Source§

const MAXVAL: u8 = 255u8

Source§

type U = u8

Source§

fn from_u8(v: u8) -> u8

Source§

fn from_unsigned(v: Wrapping<Self::U>) -> Self

Source§

fn to_unsigned(&self) -> Wrapping<Self::U>

Source§

fn fls(&self) -> u8

Source§

impl BaseOps for u16

Source§

const NUMBITS: u8 = 16u8

Source§

const MINVAL: u16 = 0u16

Source§

const MAXVAL: u16 = 65_535u16

Source§

type U = u16

Source§

fn from_u8(v: u8) -> u16

Source§

fn from_unsigned(v: Wrapping<Self::U>) -> Self

Source§

fn to_unsigned(&self) -> Wrapping<Self::U>

Source§

fn fls(&self) -> u8

Source§

impl BaseOps for u32

Source§

const NUMBITS: u8 = 32u8

Source§

const MINVAL: u32 = 0u32

Source§

const MAXVAL: u32 = 4_294_967_295u32

Source§

type U = u32

Source§

fn from_u8(v: u8) -> u32

Source§

fn from_unsigned(v: Wrapping<Self::U>) -> Self

Source§

fn to_unsigned(&self) -> Wrapping<Self::U>

Source§

fn fls(&self) -> u8

Source§

impl BaseOps for u64

Source§

const NUMBITS: u8 = 64u8

Source§

const MINVAL: u64 = 0u64

Source§

const MAXVAL: u64 = 18_446_744_073_709_551_615u64

Source§

type U = u64

Source§

fn from_u8(v: u8) -> u64

Source§

fn from_unsigned(v: Wrapping<Self::U>) -> Self

Source§

fn to_unsigned(&self) -> Wrapping<Self::U>

Source§

fn fls(&self) -> u8

Source§

impl BaseOps for u128

Source§

const NUMBITS: u8 = 128u8

Source§

const MINVAL: u128 = 0u128

Source§

const MAXVAL: u128 = 340_282_366_920_938_463_463_374_607_431_768_211_455u128

Source§

type U = u128

Source§

fn from_u8(v: u8) -> u128

Source§

fn from_unsigned(v: Wrapping<Self::U>) -> Self

Source§

fn to_unsigned(&self) -> Wrapping<Self::U>

Source§

fn fls(&self) -> u8

Source§

impl BaseOps for usize

Source§

const NUMBITS: u8 = 64u8

Source§

const MINVAL: usize = 0usize

Source§

const MAXVAL: usize = 18_446_744_073_709_551_615usize

Source§

type U = usize

Source§

fn from_u8(v: u8) -> usize

Source§

fn from_unsigned(v: Wrapping<Self::U>) -> Self

Source§

fn to_unsigned(&self) -> Wrapping<Self::U>

Source§

fn fls(&self) -> u8

Implementors§