Clamp

Trait Clamp 

Source
pub trait Clamp:
    ConstOne
    + ConstZero
    + PartialOrd {
    const MIN: Self;
    const MAX: Self;

    // Provided method
    fn clamp(self, min: Self, max: Self) -> Self { ... }
}
Expand description

Constants

Required Associated Constants§

Source

const MIN: Self

Lowest value

Negative infinity for floating point values.

assert_eq!(<i8 as Clamp>::MIN, -128);
assert_eq!(<f32 as Clamp>::MIN, f32::NEG_INFINITY);
Source

const MAX: Self

Highest value

Positive infinity for floating point values.

assert_eq!(<i8 as Clamp>::MAX, 127);

Provided Methods§

Source

fn clamp(self, min: Self, max: Self) -> Self

Clamp

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 Clamp for f32

Source§

const MIN: Self = -Inf_f32

Source§

const MAX: Self = +Inf_f32

Source§

impl Clamp for f64

Source§

const MIN: Self = -Inf_f64

Source§

const MAX: Self = +Inf_f64

Source§

impl Clamp for i8

Source§

const MIN: Self = -128i8

Source§

const MAX: Self = 127i8

Source§

impl Clamp for i16

Source§

const MIN: Self = -32_768i16

Source§

const MAX: Self = 32_767i16

Source§

impl Clamp for i32

Source§

const MIN: Self = -2_147_483_648i32

Source§

const MAX: Self = 2_147_483_647i32

Source§

impl Clamp for i64

Source§

const MIN: Self = -9_223_372_036_854_775_808i64

Source§

const MAX: Self = 9_223_372_036_854_775_807i64

Source§

impl Clamp for i128

Source§

const MIN: Self = -170_141_183_460_469_231_731_687_303_715_884_105_728i128

Source§

const MAX: Self = 170_141_183_460_469_231_731_687_303_715_884_105_727i128

Source§

impl Clamp for isize

Source§

const MIN: Self = -9_223_372_036_854_775_808isize

Source§

const MAX: Self = 9_223_372_036_854_775_807isize

Source§

impl Clamp for u8

Source§

const MIN: Self = 0u8

Source§

const MAX: Self = 255u8

Source§

impl Clamp for u16

Source§

const MIN: Self = 0u16

Source§

const MAX: Self = 65_535u16

Source§

impl Clamp for u32

Source§

const MIN: Self = 0u32

Source§

const MAX: Self = 4_294_967_295u32

Source§

impl Clamp for u64

Source§

const MIN: Self = 0u64

Source§

const MAX: Self = 18_446_744_073_709_551_615u64

Source§

impl Clamp for u128

Source§

const MIN: Self = 0u128

Source§

const MAX: Self = 340_282_366_920_938_463_463_374_607_431_768_211_455u128

Source§

impl Clamp for usize

Source§

const MIN: Self = 0usize

Source§

const MAX: Self = 18_446_744_073_709_551_615usize

Source§

impl<T: Clamp + Shift + Copy + PartialOrd, A, const F: i8> Clamp for Q<T, A, F>
where Self: ConstOne,

Source§

const MIN: Self

Lowest value

assert_eq!(Q8::<4>::MIN, (-16f32).as_());
Source§

const MAX: Self

Highest value

assert_eq!(Q8::<4>::MAX, (16.0f32 - 1.0 / 16.0).as_());

Implementors§