-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support the associated proc macro pattern (#291)
The "associated proc macro pattern" is a trick for ensuring that `zerocopy` and `zerocopy-derive` have equal verions, even when the optional `derive` feature of `zerocopy` isn't used. The `derive` feature of `zerocopy` provides a convenient way for end-users to depend on `zerocopy-derive` that ensures that `zerocopy` and `zerocopy-derive` have exactly equal versions. Unfortunately, using this feature creates a dependency between these two crates that prevents them from being built in parallel. A compile-time-conscious user of `zerocopy` can avoid this by depending on both of these crates explicitly, but this places the onus on them to ensure that their versions are exactly equal. The "associated proc macro pattern" is a trick for ensuring that `zerocopy` and `zerocopy-derive` have equal verions, even when the optional `derive` feature of `zerocopy` isn't used. With it, an end-user of zerocopy can write: [dependencies] zerocopy = "MAJOR.MINOR" zerocopy-derive = "MAJOR.MINOR" ...and cargo will ensure that the actual versions that are used are exactly equal. For more information, see: https://github.com/matklad/macro-dep-test
- Loading branch information
Showing
5 changed files
with
111 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
[package] | ||
edition = "2021" | ||
name = "zerocopy" | ||
version = "0.7.0" | ||
version = "0.7.1" | ||
authors = ["Joshua Liebow-Feeser <[email protected]>"] | ||
description = "Utilities for zero-copy parsing and serialization" | ||
license = "BSD-2-Clause" | ||
|
@@ -55,13 +55,19 @@ simd-nightly = ["simd"] | |
__internal_use_only_features_that_work_on_stable = ["alloc", "simd"] | ||
|
||
[dependencies] | ||
zerocopy-derive = { version = "=0.7.0", path = "zerocopy-derive", optional = true } | ||
zerocopy-derive = { version = "=0.7.1", path = "zerocopy-derive", optional = true } | ||
|
||
[dependencies.byteorder] | ||
version = "1.3" | ||
default-features = false | ||
optional = true | ||
|
||
# The "associated proc macro pattern" ensures that the versions of zerocopy and | ||
# zerocopy-derive remain equal, even if the 'derive' feature isn't used. | ||
# See: https://github.com/matklad/macro-dep-test | ||
[target.'cfg(any())'.dependencies] | ||
zerocopy-derive = { version = "=0.7.1", path = "zerocopy-derive" } | ||
|
||
[dev-dependencies] | ||
rand = "0.6" | ||
rustversion = "1.0" | ||
|
@@ -72,4 +78,4 @@ static_assertions = "1.1" | |
# CI test failures. | ||
trybuild = "=1.0.80" | ||
# In tests, unlike in production, zerocopy-derive is not optional | ||
zerocopy-derive = { version = "=0.7.0", path = "zerocopy-derive" } | ||
zerocopy-derive = { version = "=0.7.1", path = "zerocopy-derive" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
[package] | ||
edition = "2021" | ||
name = "zerocopy-derive" | ||
version = "0.7.0" | ||
version = "0.7.1" | ||
authors = ["Joshua Liebow-Feeser <[email protected]>"] | ||
description = "Custom derive for traits from the zerocopy crate" | ||
license = "BSD-2-Clause" | ||
|