pub trait Restrict<RangeType> {
// Required method
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§
Sourcefn restrict(self, range: RangeType) -> Self
fn restrict(self, range: RangeType) -> Self
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.
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.