Idea: Coercible trait #1896
Labels
T-lang
Relevant to the language team, which will review and decide on the RFC.
T-libs-api
Relevant to the library API team, which will review and decide on the RFC.
GHC implements a two-paramenter type class called
Coercible
and a corresponding safe functioncoerce
, with the following types:This allows the following:
Without coerce, this would require
unsafeCoerce
(GHC's version ofmem::transmute
) or an O(n) mapping over the list.In Rust, the same problem can arise. It would be nice to support something like this.
The text was updated successfully, but these errors were encountered: