Idea: Relax orphan rule and remove the need for `TryFrom`

#1

I am thinking if we could just write

impl<T,R,E> From<T> for Result<R,E> {...}

we don’t actually need TryFrom. Is there a way we can relax the orphan rule to allow something like this (with some reasonable restrictions)?

0 Likes

#2

You can already write Into<Result<R, E>> for T {} given some types T, R, E if you own T. But this is different from TryFrom. With TryFrom there is still only 1 way to go from T to R, but with your way there could be many ways to go from T to R just by giving a different error type. This seems bad. Also it seems bad to relax the orphan rules for 1 specific impl type (I would like to reduce special casing random stuff).

3 Likes