Closed phayes closed 6 years ago
Often times, it is useful to know the maximum and minimum values allowed by a numeric type.
I'm hoping we could see a fairly simple trait that looks someting like this:
pub trait MiniMax { fn maximum() -> Self; fn minimum() -> Self; }
Some examples:
u32.maximum()
std::u32::MAX
u32.minimum()
0
f64.maximum()
std::f64::INFINITY
f64.minimum()
std::f64::NEG_INFINITY
Unbounded finite types like BigInt simply wouldn't implement this trait.
That would be Bounded, although for floats it returns the min/max finite values.
Bounded
Silly me, there it is. Apologies for the noise on the issue queue. Closing this.
Often times, it is useful to know the maximum and minimum values allowed by a numeric type.
I'm hoping we could see a fairly simple trait that looks someting like this:
Some examples:
u32.maximum()
would returnstd::u32::MAX
u32.minimum()
would return0
f64.maximum()
would returnstd::f64::INFINITY
f64.minimum()
would returnstd::f64::NEG_INFINITY
Unbounded finite types like BigInt simply wouldn't implement this trait.