Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeserializeOwned not work with derive macro #2771

Open
sineptic opened this issue Jul 7, 2024 · 1 comment
Open

DeserializeOwned not work with derive macro #2771

sineptic opened this issue Jul 7, 2024 · 1 comment

Comments

@sineptic
Copy link

sineptic commented Jul 7, 2024

It's not compile:

pub trait A: Serialize + DeserializeOwned {}

#[derive(Serialize, Deserialize)]
pub struct B<T: A> {
    t: T,
}

and generates 90 lines of unuseful errors

@sineptic
Copy link
Author

sineptic commented Jul 8, 2024

It compiles:

pub trait A: Serialize + DeserializeOwned {}

#[derive(Serialize, Deserialize)]
#[serde(bound(deserialize = "T: A"))]
pub struct B<T> {
    t: T,
}

but it's no:

#[derive(Serialize, Deserialize)]
pub struct B<T: A> {
    t: T,
}

WHY???

And also why first example compiles and serializes if bound only for deserializing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant