Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Design: implementing traits over enums (e.g. Result) #18

Open
jtempest opened this issue Jul 24, 2020 · 0 comments
Open

Design: implementing traits over enums (e.g. Result) #18

jtempest opened this issue Jul 24, 2020 · 0 comments

Comments

@jtempest
Copy link
Owner

jtempest commented Jul 24, 2020

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_eq comparison 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant