Width

Trait Width 

Source
pub trait Width: Ord + Clone {
    type Output: Unsigned + Integer + Clone;

    // Required methods
    fn min_value() -> Self;
    fn max_value() -> Self;
    fn width(lower: &Self, upper: &Self) -> Self::Output;
}
Expand description

Limits of a bound for which the distance between min_value() and max_value() can be represented in the type Output.

Required Associated Types§

Required Methods§

Source

fn min_value() -> Self

Smallest value representable by the range.

Source

fn max_value() -> Self

Largest value representable by the range.

Source

fn width(lower: &Self, upper: &Self) -> Self::Output

The result might be infinite depending on the underlying type, for example floating types.

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

Source§

type Output = u8

Source§

fn max_value() -> i8

Source§

fn min_value() -> i8

Source§

fn width(lower: &i8, upper: &i8) -> u8

Source§

impl Width for i16

Source§

type Output = u16

Source§

fn max_value() -> i16

Source§

fn min_value() -> i16

Source§

fn width(lower: &i16, upper: &i16) -> u16

Source§

impl Width for i32

Source§

type Output = u32

Source§

fn max_value() -> i32

Source§

fn min_value() -> i32

Source§

fn width(lower: &i32, upper: &i32) -> u32

Source§

impl Width for i64

Source§

type Output = u64

Source§

fn max_value() -> i64

Source§

fn min_value() -> i64

Source§

fn width(lower: &i64, upper: &i64) -> u64

Source§

impl Width for isize

Source§

impl Width for u8

Source§

type Output = u8

Source§

fn max_value() -> u8

Source§

fn min_value() -> u8

Source§

fn width(lower: &u8, upper: &u8) -> u8

Source§

impl Width for u16

Source§

type Output = u16

Source§

fn max_value() -> u16

Source§

fn min_value() -> u16

Source§

fn width(lower: &u16, upper: &u16) -> u16

Source§

impl Width for u32

Source§

type Output = u32

Source§

fn max_value() -> u32

Source§

fn min_value() -> u32

Source§

fn width(lower: &u32, upper: &u32) -> u32

Source§

impl Width for u64

Source§

type Output = u64

Source§

fn max_value() -> u64

Source§

fn min_value() -> u64

Source§

fn width(lower: &u64, upper: &u64) -> u64

Source§

impl Width for usize

Implementors§