Skip to content

Commit

Permalink
Eliminate dependency on serde's "derive" feature (#694)
Browse files Browse the repository at this point in the history
This allows serde, and other crates downstream of it like serde_json, to
compile in parallel with serde_derive. Without this PR, in any
dependency graph that pulls in serde_with, first serde_derive would need
to compile, then serde would need to compile, then serde_json would need
to compile.

sharkdp/bat#2815 has a diagram of the impact of
this change.
  • Loading branch information
jonasbb committed Feb 8, 2024
2 parents d145a45 + 5e6a115 commit 6211d20
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions serde_with/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,8 @@ hex = {version = "0.4.3", optional = true, default-features = false}
indexmap_1 = {package = "indexmap", version = "1.8", optional = true, default-features = false, features = ["serde-1"]}
indexmap_2 = {package = "indexmap", version = "2.0", optional = true, default-features = false, features = ["serde"]}
schemars_0_8 = {package = "schemars", version = "0.8.16", optional = true, default-features = false}
# The derive feature is needed for the flattened_maybe macro.
# https://github.com/jonasbb/serde_with/blob/eb1965a74a3be073ecd13ec05f02a01bc1c44309/serde_with/src/flatten_maybe.rs#L67
serde = {version = "1.0.152", default-features = false, features = ["derive"] }
serde = {version = "1.0.152", default-features = false}
serde_derive = "1.0.152"
serde_json = {version = "1.0.45", optional = true, default-features = false}
serde_with_macros = {path = "../serde_with_macros", version = "=3.6.0", optional = true}
time_0_3 = {package = "time", version = "~0.3.11", optional = true, default-features = false}
Expand All @@ -149,6 +148,7 @@ rmp-serde = "1.1.0"
ron = "0.8"
rustversion = "1.0.0"
schemars_0_8 = {package = "schemars", version = "0.8.16"}
serde = {version = "1.0.152", default-features = false, features = ["derive"]}
serde_json = {version = "1.0.25", features = ["preserve_order"]}
serde_test = "1.0.124"
serde_yaml = "0.9.2"
Expand Down
2 changes: 1 addition & 1 deletion serde_with/src/flatten_maybe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ macro_rules! flattened_maybe {
serde,
};

#[derive($crate::serde::Deserialize)]
#[derive($crate::serde_derive::Deserialize)]
#[serde(crate = "serde")]
pub struct Both<T> {
#[serde(flatten)]
Expand Down
2 changes: 2 additions & 0 deletions serde_with/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ extern crate alloc;
pub extern crate core;
#[doc(hidden)]
pub extern crate serde;
#[doc(hidden)]
pub extern crate serde_derive;
#[cfg(feature = "std")]
extern crate std;

Expand Down

0 comments on commit 6211d20

Please sign in to comment.