Hello all. I hope you're having a good day, and if not, that it gets better.
The state of getting the greatest and least values for some type is a bit limited at the moment (associated
MIN constants on primitive types and whatnot). I would like to write an RFC to propose introducing traits with associated constants for these values to the standard library, along with a few new features to the Range types that are enabled by this, but I have some questions first.
I've tried to find a previous RFC for this feature and haven't found any. Does anyone know if one exists, or if/where there has been any prior discussion about this feature?
There are a number of forms of extrema for partially ordered types. This is relevant to consider because floating-point types aren't totally ordered, and it would be a real shame if those traits couldn't be implemented for
f64. Given this:
Should the proposal include a trait for getting the maxima or minima of a type? Minima and maxima are the values of a type for which there are no other values that are less or greater (respectively) than them. Partially ordered types may have multiple of each.
In order for a greatest/least value trait to be implemented for floating-point types, it'd have to be restricted to the set of finite values of those floating-point types. Should there additionally be a trait that doesn't have this restriction? What about a trait to identify values that are part of the ordering between the "finite greatest" and "finite least" values?
After adding these traits, some of the aforementioned associated constants would be redundant. It would be nice to suggest a course of action to take with those constants for an edition after the inclusion of this feature. Should they be kept indefinitely, replaced with corresponding traits being added to the prelude, or just removed with no corresponding prelude additions?