See the playground example here: Rust Playground
I want to provide a fmt::Display implementation for all traits that implement my own custom trait but it fails with the errors below. Is there any other way for me to work-around this without having to manually implement fmt::Display for all structs that implement Foo
?
error[E0119]: conflicting implementations of trait `std::fmt::Display` for type `&_`:
--> src/lib.rs:5:1
|
5 | impl <T: Foo + Sized> std::fmt::Display for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: conflicting implementation in crate `core`:
- impl<T> std::fmt::Display for &T
where T: std::fmt::Display, T: ?Sized;
= note: downstream crates may implement trait `Foo` for type `&_`
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
--> src/lib.rs:5:7
|
5 | impl <T: Foo + Sized> std::fmt::Display for T {
| ^ type parameter `T` must be used as the type parameter for some local type
|
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local
= note: only traits defined in the current crate can be implemented for a type parameter
error: aborting due to 2 previous errors