I have a wrapper type and I want to implement From for it for all types that the inner type has From implemented for.
Unfortunately it seems that this conflicts with a blanket implementation from the standard library that implements From for itself.
Is there a way to work around this?
struct Outer<T> {
inner: T
}
impl <E, T> From<E> for Outer<T> where T: From<E> {
fn from(source: E) -> Self {
Self {
inner: T::from(source).into()
}
}
}
error[E0119]: conflicting implementations of trait `std::convert::From<Outer<_>>` for type `Outer<_>`
--> src/lib.rs:5:1
|
5 | impl <E, T> From<E> for Outer<T> where T: From<E> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: conflicting implementation in crate `core`:
- impl<T> From<T> for T;
Concretely I'm trying to copy this pattern (from the example) https://docs.rs/tracing-error/latest/tracing_error/struct.TracedError.html, but I want the Kind to be generic so that I don't have to copy paste the wrapper struct
A browser interface to the Rust compiler to experiment with the language