How to use items which don't implement PartialOrd/Ord in a BTreeMap?

297 Views Asked by At

There is a third-party type T which doesn't implement Ord.

I need a map, with keys of type T, which has a deterministic serialization.

For every other type I just use BTreeMap<X, Y>, where X implements PartialOrd and Ord.

I can't implement PartialOrd and Ord for T as T is not defined in my crate.

How can I make a map from T to Y, with a deterministic serialization?

0

There are 0 best solutions below