Using 3rd party enums as keys in maps

I'm using a library which provides an enum, whose variants I would like to use as keys in a hash and/or btree map. The library's enum doesn't implement Hash or Ord.

Can I do better than go through the whole newtype pattern song-and-dance by hand?

No. You can't even use a macro to automate it because macros cannot look into types not defined inside the macro invocation.

1 Like

Ask the library maintainer to add these derives.

4 Likes