I want my trait to depend on Serde's:
pub trait MyTrait: Serialize + DeserializeOwned {}
#[derive(Serialize, Deserialize)]
pub struct MyStruct<T: MyTrait> {
value: T,
}
impl MyTrait for i32 {}
impl MyTrait for MyStruct<i32> {}
But I get this error:
error[E0283]: type annotations required: cannot resolve `T: serde::Deserialize<'de>`
--> src/main.rs:11:21
|
11 | #[derive(Serialize, Deserialize)]
| ^^^^^^^^^^^
|
= note: required by `serde::Deserialize`
I have no idea what that means in this context. I don't understand how it relates to the info about E0283.
(I think that DeserializeOwned is what I want based on the Serde lifetimes info, but I can't find anything on "extending" traits, so I might be wrong).