A Second<E> can store an ErrorContext<E>, however in your From implementation you're trying to give it a ErrorContext<First<E>>.
To solve this you can either store an ErrorContext<First<E>> in Second::F or get the inner ErrorContext<E> from previous before calling ErrorContext::new
You might be be confusing this with OOP and garbage collected languages like Java where you can assign an instance of a type to a variable that expect an interface it implements. That's possible because everything is a pointer and interfaces are implemented with dynamic dispatch.
In rust however static dispatch is the default one. ErrorContext<E> and ErrorContext<First<E>> are different types and you can't store one where the other is expected. The fact that E and First<E> both implement the same trait doesn't matter.
I can write same code that will compile. Thanks for your advice.
But i want to know what problem in that code. E - is generic type, First<W> is concrete type for E.
The code below:
has Some(E: Error) as Some(previous),where previous is First<W> and we have impl<E> Error for First<E> where E: Error {} at same time. So, the rule about working with generics is performed.
We include different meanings in words "concrete type for generic."
A concrete implementation and subsequent compilation implies the definition of generic-parameters. In this code in place of E there will always be First <W>, where enum First will never change, so here we can consider it a concrete type.
"expected type parameter E, found enum First" - compilator said;
So, For all W: Error in First<W> we have Error trait implementation.
Generic E accept any type that has Error trait implementation.
It must be compiled
That's not how it works. The concrete type for E is choosen by the user of your implementation.
It's not that it can accept any type that implement the Error trait, it must accept any type that implement the Error type. So what happens if a downstream user use your implementation where E is not First<W>? i.e. what should <Second<Foo> as From<First<Bar>>>::from(previous) do, assuming Foo and Bar both implement Error? The implementation would try to store First<Bar> where a Foo would be expected, and that's not possible.