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)?
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)?
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).
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.