Introduce trait for (forced) total ordering of numbers - #381
Conversation
|
We already have this, but for floats only: Can you say more about why you want the same trait for integers? |
|
Mostly to be able to treat float numbers and integers uniformly in containers that don't really care about special float values and just need an arbitrary, but deterministic ordering for them, optimally to shift the burden away from the user of having to wrap float values in a wrapper that forwards In particularly, this applies to containers like priority queues or R-trees. |
099ecae to
09e60fc
Compare
| macro_rules! totalorder_impl_zeroable_via_ord_core { | ||
| ($($t:ty),* $(,)?) => { | ||
| $( | ||
| impl TotalOrder for NonZero<$t> { |
There was a problem hiding this comment.
Okay, only remaining problem afaik is that NonZero requires a bump of MSRV to 1.79
a195803 to
9e5bd02
Compare
|
I refactored this to minimize the amount of code generated by macros, by using generic trait impls instead. |
| } | ||
|
|
||
| totalorder_impl_zeroable_via_ord_core!( | ||
| char, i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize, |
There was a problem hiding this comment.
Weirdly enough char: ZeroablePrimitive, but NonZeroChar doesn't exist...
Motivation: georust/rstar#237 (comment)