num_bound
Trait that adds a bound function enabling to restrict a number to a range.
Automatically implemented for anything that implements std trait Ord.
V1 Breaking change
Removed the requirement to operate only on references.
Previously this worked:
let number = 19;
let upper = 60;
let low = 10;
assert_eq!(number.bound(&low, &upper), &number);
Now the bound method doesn't take self as ref so the equivilant is now:
assert_eq!(number.as_ref().bound(&low, &upper), &number);
However unless passing references is preferred, copy should suffice:
assert_eq!(number.bound(low, upper), number);
Only use references if type is larger than a reference.
Usage
bound(self, lower: Self, upper: Self) -> Self
use Bound;