[][src]Trait pixel_canvas::math::Restrict

pub trait Restrict<RangeType> {
    pub fn restrict(self, range: RangeType) -> Self;
}

Represent types that can be restricted by a given range type.

This would've been called Clamp, except that there's a standard library method called clamp.

Required methods

pub fn restrict(self, range: RangeType) -> Self[src]

Restrict a value into a given range.

If a value is below the minimum bound, it should be clamped to that value, and if it's above its max value it should be clamped to that. This is only provided for inclusive ranges, since the behavior for exclusive ranges of some types are less immediately clear.

Loading content...

Implementors

impl<T> Restrict<RangeFrom<T>> for T where
    T: PartialOrd
[src]

impl<T> Restrict<RangeInclusive<T>> for T where
    T: PartialOrd
[src]

impl<T> Restrict<RangeToInclusive<T>> for T where
    T: PartialOrd
[src]

Loading content...