Trait pixel_game_lib::Clamp 
source · pub trait Clamp<Bound = Self>: Sized {
    // Required method
    fn clamped(self, lower: Bound, upper: Bound) -> Self;
    // Provided methods
    fn clamped_to_inclusive_range(self, range: RangeInclusive<Bound>) -> Self { ... }
    fn clamp(val: Self, lower: Bound, upper: Bound) -> Self { ... }
    fn clamp_to_inclusive_range(val: Self, range: RangeInclusive<Bound>) -> Self { ... }
    fn clamped01(self) -> Self
       where Bound: Zero + One { ... }
    fn clamp01(val: Self) -> Self
       where Bound: Zero + One { ... }
    fn clamped_minus1_1(self) -> Self
       where Bound: One + Neg<Output = Bound> { ... }
    fn clamp_minus1_1(val: Self) -> Self
       where Bound: One + Neg<Output = Bound> { ... }
}Expand description
Re-export vek types. A scalar or vector that can be constrained to be between two values (inclusive).
Required Methods§
sourcefn clamped(self, lower: Bound, upper: Bound) -> Self
 
fn clamped(self, lower: Bound, upper: Bound) -> Self
Constrains this value to be between lower and upper (inclusive).
Panics
Panics if lower is greater than upper. Swap the values yourself if necessary.
use vek::ops::Clamp;
assert_eq!(7.clamped(5, 10), 7);
assert_eq!(4.clamped(5, 10), 5);
assert_eq!(5.clamped(5, 10), 5);
assert_eq!(10.clamped(5, 10), 10);
assert_eq!(11.clamped(5, 10), 10);Provided Methods§
sourcefn clamped_to_inclusive_range(self, range: RangeInclusive<Bound>) -> Self
 
fn clamped_to_inclusive_range(self, range: RangeInclusive<Bound>) -> Self
Alias to clamped, which accepts a RangeInclusive parameter instead of two values.
sourcefn clamp(val: Self, lower: Bound, upper: Bound) -> Self
 
fn clamp(val: Self, lower: Bound, upper: Bound) -> Self
Alias to clamped, which doesn’t take self.
Panics
Panics if lower is greater than upper. Swap the values yourself if necessary.
sourcefn clamp_to_inclusive_range(val: Self, range: RangeInclusive<Bound>) -> Self
 
fn clamp_to_inclusive_range(val: Self, range: RangeInclusive<Bound>) -> Self
Alias to clamp, which accepts a RangeInclusive parameter instead of two values.
sourcefn clamped_minus1_1(self) -> Self
 
fn clamped_minus1_1(self) -> Self
Constrains this value to be between -1 and 1 (inclusive).
sourcefn clamp_minus1_1(val: Self) -> Self
 
fn clamp_minus1_1(val: Self) -> Self
Alias to clamped_minus1_1, which doesn’t take self.
Object Safety§
This trait is not object safe.