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

Suggestion: derive Cargo feature #5

Open
RReverser opened this issue Jan 15, 2021 · 4 comments
Open

Suggestion: derive Cargo feature #5

RReverser opened this issue Jan 15, 2021 · 4 comments

Comments

@RReverser
Copy link

Nowadays, in serde the recommended way to import derives is to use serde = { version = ..., features = ["derive"] } in Cargo.toml. It takes care of reexporting the macros, to instead of writing

use serde::{Serialize, Deserialize};
use serde_derive::{Serialize, Deserialize};

to import both traits and derives you can just write

use serde::{Serialize, Deserialize};

Would it be possible to make serde_state have the same feature so that derives would be automatically included under corresponding trait names?

@Marwes
Copy link
Owner

Marwes commented Jan 18, 2021

This may be fixed if we do another merge from serde upstream, though that can be quite annoying at times.

@RReverser
Copy link
Author

@Marwes Is there any way to detach them / reuse serde bits via public APIs instead?

@Marwes
Copy link
Owner

Marwes commented Jan 18, 2021

No, this is basically serde_derive but modified to thread a state argument through. serde_derive itself does not (and could not, without seriously invasive changes) expose an API for this.

@RReverser
Copy link
Author

serde_derive itself does not (and could not, without seriously invasive changes) expose an API for this.

They do have serde_derive_internals - that API is not stable either, but maybe sufficient? Just thinking of ways to make upgrades a bit easier.

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

No branches or pull requests

2 participants