-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix no_std support if serde is depended on
The proc-macro-crate depends on toml, which in turn depends on serde _with_ std. Only depend on proc-macro-crate if std is enabled. This means that no_std consumer of num_enum cannot rename their num_enum dependency. This seems like a reasonable restriction. Works around rust-lang/cargo#5730
- Loading branch information
1 parent
fc199d0
commit 34012e6
Showing
6 changed files
with
56 additions
and
13 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[workspace] | ||
members = ["num_enum", "num_enum_derive", "renamed_num_enum"] | ||
members = ["num_enum", "num_enum_derive", "renamed_num_enum", "serde_example"] | ||
# Exclude num_enum_derive because its useful doc comments import num_enum, which the crate doesn't do (because it would | ||
# cause a circular dependency), so the doc tests don't actually compile. | ||
default-members = ["num_enum", "renamed_num_enum"] | ||
default-members = ["num_enum", "renamed_num_enum", "serde_example"] |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "serde_example" | ||
version = "0.1.0" | ||
authors = [ | ||
"Daniel Wagner-Hall <[email protected]>", | ||
"Daniel Henry-Mantilla <[email protected]>", | ||
] | ||
description = "Example crate using num_enum and serde. Regression test for https://github.com/illicitonion/num_enum/issues/18." | ||
edition = "2018" | ||
repository = "https://github.com/illicitonion/num_enum" | ||
publish = false | ||
|
||
[dependencies] | ||
num_enum = { path = "../num_enum", default-features = false } | ||
serde = { version = "1", default_features = false, features = ["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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#![no_std] | ||
|
||
use num_enum::{IntoPrimitive, TryFromPrimitive, UnsafeFromPrimitive}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Deserialize, IntoPrimitive, Serialize, TryFromPrimitive, UnsafeFromPrimitive)] | ||
#[repr(u8)] | ||
pub enum Number { | ||
Zero, | ||
One, | ||
} |