num-traits icon indicating copy to clipboard operation
num-traits copied to clipboard

Add unconditionally implemented (potentially) open-ended bounds

Open tyilo opened this issue 5 months ago • 0 comments

I have a use-case for a function supporting both big integers and primitive integers. It would be useful to be able to get the minimum and maximum value as an Option<T> at runtime, without having to use a generic info.

Type Bounds
BigInt ..
BigUInt 0..
T: Bounded T::min_value()..=T::max_value()

This could be implemented as:

trait FiniteRange {
    fn min_value() -> Option<Self>;
    fn max_value() -> Option<Self>;
}

tyilo avatar May 22 '25 12:05 tyilo