Why can't I `impl<E> From<E> for EzError where E: StdError + Send`?

You can't, if the impl may apply to the source type as well, due to the identity impl<T> From<T> for T.

Even worse, EzError(Box::new(e)) would result in the identity impl suddenly allocating an unnecessary linked list, instead of doing nothing every time it's called.

You would need some kind of variant of specialization, or a where E != EzError bound (cc @nikomatsakis).

1 Like