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

#[bincode(bound)] for generic types #511

Closed
coolreader18 opened this issue Feb 28, 2022 · 3 comments · Fixed by #526
Closed

#[bincode(bound)] for generic types #511

coolreader18 opened this issue Feb 28, 2022 · 3 comments · Fixed by #526

Comments

@coolreader18
Copy link

I'm looking into switching to bincode v2 and I'd love to get rid of serde - the only thing that seems to be lacking in the derive macros is that I can't specify custom bounds for generics. e.g.:

#[derive(Encode, Decode)]
struct A<B: MyTrait> {
    foo: usize,
    b: B,
    thing: B::Assoc,
}

With serde, I had a #[serde(bound(deserialize = "B::Assoc: serde::Deserialize<'de>", serialize = "B::Assoc: serde::Serialize"))]; it'd be awesome to have a similar feature for bincode v2's derive.

@coolreader18
Copy link
Author

Oh, also, this is the generated code for a type with a default type param:

impl<C: Constant = ConstantData> ::bincode::Encode for CodeObject<C>

which is invalid syntax.

@VictorKoenders
Copy link
Contributor

This is being implemented as a part of #526. We'll have to start splitting the Decode and BorrowDecode trait, which might take a while.

@VictorKoenders VictorKoenders added this to the v2.0 milestone Apr 1, 2022
@VictorKoenders VictorKoenders linked a pull request Apr 8, 2022 that will close this issue
@stale
Copy link

stale bot commented May 31, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

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

Successfully merging a pull request may close this issue.

2 participants