Skip to content
This repository has been archived by the owner on Sep 11, 2023. It is now read-only.

Derive Eq, Ord, PartialEq and PartialOrd on EnumMap<K,V> when K and V impl those traits #28

Closed
klauria-factorial opened this issue Aug 30, 2022 · 2 comments

Comments

@klauria-factorial
Copy link

This would be broadly useful when using EnumMap<K,V> inside other structs where it's nice to be able to compare by value. If you think this would be good to add, I'm happy to take a shot, especially if you have some thoughts/opinions on how you think it should be done!

Thank you!

@KamilaBorowska
Copy link
Owner

EnumMap already implements Eq and PartialEq.

As for Ord, the issue is mostly it's not clear how it should be implemented and currently I didn't want to decide on any particular implementation.

@klauria-factorial
Copy link
Author

If V implements Ord, I would naively think that a fixed-length array of V's can implement Ord by lexicographic comparison of elements. Would that have some downside I'm not thinking of?

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

No branches or pull requests

2 participants