Skip to content

Add a #[serde(crate_name = "…")] attribute #953

Closed
@SimonSapin

Description

@SimonSapin

servo/rust-url#327 proposes depending on multiple versions of serde at the same time, in order to add support for new (semver-incompatible) versions without removing support for old ones (which would be a breaking change). This is done by not depending on the serde crate directly, but depending on serde1 which itself depends on serde = "1.0" and re-exports pub use serde::*;.

However this prevents using derive because the code generated by derive includes its own extern crate serde;. I’d like an attribute to be added to control the name of the crate in the generated extern crate code. Something like:

#[derive(Serialize, Deserialize)]
#[serde(crate_name = "serde1")]
enum {
    Foo,
    Bar(u32),
    Baz(String),
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions