Skip to main content

UnitIntervalFloat

Trait UnitIntervalFloat 

Source
pub trait UnitIntervalFloat:
    Sealed
    + Copy
    + PartialOrd
    + Add<Output = Self>
    + Sub<Output = Self>
    + Mul<Output = Self>
    + Div<Output = Self> {
    const ZERO: Self;
    const NEG_ONE: Self;
    const ONE: Self;
    const HALF: Self;

    // Required methods
    fn clamp_unit(self) -> Self;
    fn clamp_signed_unit(self) -> Self;
}
Expand description

Floating-point support required by UnitInterval.

This trait is sealed and implemented only for f32 and f64.

Required Associated Constants§

Source

const ZERO: Self

The additive identity, 0.

Source

const NEG_ONE: Self

The lower bound of the signed unit interval, -1.

Source

const ONE: Self

The multiplicative identity, 1.

Source

const HALF: Self

The midpoint value, 0.5.

Required Methods§

Source

fn clamp_unit(self) -> Self

Clamps a value into [0, 1].

Implementations treat NaN as zero.

Source

fn clamp_signed_unit(self) -> Self

Clamps a value into [-1, 1].

Implementations treat NaN as zero.

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

Source§

const ZERO: Self = 0.0

Source§

const NEG_ONE: Self = -1.0

Source§

const ONE: Self = 1.0

Source§

const HALF: Self = 0.5

Source§

fn clamp_unit(self) -> Self

Source§

fn clamp_signed_unit(self) -> Self

Source§

impl UnitIntervalFloat for f64

Source§

const ZERO: Self = 0.0

Source§

const NEG_ONE: Self = -1.0

Source§

const ONE: Self = 1.0

Source§

const HALF: Self = 0.5

Source§

fn clamp_unit(self) -> Self

Source§

fn clamp_signed_unit(self) -> Self

Implementors§