Clamp

Trait Clamp 

Source
pub trait Clamp: Sized + PartialOrd {
    // Required methods
    fn clamp_min() -> Self;
    fn clamp_max() -> Self;
    fn is_clamp_nan(&self) -> bool;

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

Trait for scalar values which have a “clamped” range.

For integer values, the clamped range is from 0 to $ty::MAX. For floating point values, the clamped range is from 0.0 to 1.0.

Required Methods§

Source

fn clamp_min() -> Self

Source

fn clamp_max() -> Self

Source

fn is_clamp_nan(&self) -> bool

Provided Methods§

Source

fn clamp(self) -> Self

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§

impl Clamp for f64

Source§

impl Clamp for i8

Source§

impl Clamp for i16

Source§

impl Clamp for i32

Source§

impl Clamp for i64

Source§

impl Clamp for isize

Source§

impl Clamp for u8

Source§

impl Clamp for u16

Source§

impl Clamp for u32

Source§

impl Clamp for u64

Source§

impl Clamp for usize

Implementors§