Trait wiwi::num::Widening

source ·
pub trait Widening<Wide>: Base {
    // Required methods
    fn widen(self) -> Wide;
    fn split(wide: Wide) -> (Self, Self);
    fn join(self, n_high: Self) -> Wide;
}
Expand description

Numbers that can be “widened” to another number type that’s double its size

Required Methods§

source

fn widen(self) -> Wide

Extend self out into the widened type (without changing its value)

source

fn split(wide: Wide) -> (Self, Self)

Splits the wide integer into its lower and upper Self parts

The returned value is (low, high), ie. first element is the lower half, and the second element is the upper half, ie. little endian order.

source

fn join(self, n_high: Self) -> Wide

Joins self with an upper value, to give a widened value

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Widening<u16> for u8

source§

fn widen(self) -> u16

source§

fn split(wide: u16) -> (u8, u8)

source§

fn join(self, n_high: u8) -> u16

source§

impl Widening<u32> for u16

source§

fn widen(self) -> u32

source§

fn split(wide: u32) -> (u16, u16)

source§

fn join(self, n_high: u16) -> u32

source§

impl Widening<u64> for u32

source§

fn widen(self) -> u64

source§

fn split(wide: u64) -> (u32, u32)

source§

fn join(self, n_high: u32) -> u64

source§

impl Widening<u128> for u64

source§

fn widen(self) -> u128

source§

fn split(wide: u128) -> (u64, u64)

source§

fn join(self, n_high: u64) -> u128

source§

impl Widening<u128> for usize

source§

fn widen(self) -> u128

source§

fn split(wide: u128) -> (usize, usize)

source§

fn join(self, n_high: usize) -> u128

source§

impl Widening<usize> for u32

source§

fn widen(self) -> usize

source§

fn split(wide: usize) -> (u32, u32)

source§

fn join(self, n_high: u32) -> usize

Implementors§