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

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

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.

Implementors