@jmst I’ll try to summarize your proposal as good as I can. You propose to add an auto trait:
auto trait Compatible<T> {
fn from_compatible(T) -> Self; // needed for the explicit impls
}
that:
- is automatically derived for all permutations of two equally-sized equally-aligned types with whose fields are all public,
- allows coercing
TasSelf, e.g., usingSelf::from_compatible(T)(or some other syntax) - is transitive: allows coercing
TasV, ifCompatible<T> for UandCompatible<U> for V
For types with private fields, the users would need to specify this trait manually for the relations they care about and due to transitivity the compiler would “fill in the blanks” from the relations the users specifies to the relations the target types support.
Is that it?