Expand description

A trait to represent zero-cost conversions.

Traits

A marker trait such that the existence of From: Coerce<To> implies that From can be treat as To without any data manipulation. Particularly useful for containers, e.g. Vec<From> can be treated as Vec<To> in O(1). If such an instance is available, you can use coerce to perform the conversion.
A marker trait such that the existence of From: CoerceKey<To> implies that From can be treat as To without any data manipulation. Furthermore, above and beyond Coerce, any provided Hash, Eq, PartialEq, Ord and PartialOrd traits must give identical results on the From and To values.

Functions

Safely convert between types which have a Coerce relationship. Often the second type argument will need to be given explicitly, e.g. coerce::<_, ToType>(x).

Derive Macros