float_eq-rs
float_eq-rs copied to clipboard
Design: implementing traits over enums (e.g. Result)
The design principles of float_eq make enums difficult to implement the extension traits over, since as it stands all branches of the enum would need to be a floating point type. This obviously makes it difficult to implement for a type like Result, where it is likely that only one of the result type or error type would be comparable. I believe that a way forward would involve thinking through one or more of these options in detail:
- Implementation only over main result type T (such that the error type is either never equal or using PartialEq).
- Specialisation over either T, E or both (requires specialisation to be stabilised).
- Blanket implementation of
float_eqcomparison traits over non-floating point types (also requires specialisation?).
Therefore, I'm leaving this issue here in case it becomes viable in future, but for now I'm leaving enums (and therefore Result) be.