Repository: Peternator7/strum
Pull request #61 (2019-08-13 02:51:38)

Update attribute docs for strum_discriminants
Currently the README does not mention that extra attributes may be
passed to `#[strum_discriminants()]` and that these will be added as
attributes on the generated enum.  This is a cool feature, we should
document it.


Patch:
diff --git a/README.md b/README.md
index 031c2c1..87fb1f8 100644
--- a/README.md
+++ b/README.md
@@ -437,6 +437,10 @@ fn main() {
 }
 ```
 
+When using `#[strum_discriminants()], the derive parameter may be followed by
+additional attributes and these will be expanded as attributes on the generated
+enum e.g. `#[strum_discriminants(name(SomeOtherName), derive(Serialize), serde(rename_all = "SCREAMING_SNAKE_CASE"))]`
+
 The derived enum also has the following trait implementations:
 
 * `impl From<MyEnum> for MyEnumDiscriminants`
diff --git a/strum/Cargo.toml b/strum/Cargo.toml
index 59ba2e8..38fecdf 100644
--- a/strum/Cargo.toml
+++ b/strum/Cargo.toml
@@ -12,8 +12,14 @@ documentation = "https://docs.rs/strum"
 homepage = "https://github.com/Peternator7/strum"
 readme = "../README.md"
 
+[dependencies]
+strum_macros = { path = "../strum_macros", optional = true, version = "0.15.0" }
+
 [dev-dependencies]
 strum_macros = { path = "../strum_macros", version = "0.15.0" }
 
 [badges]
-travis-ci = { repository = "Peternator7/strum" }
\ No newline at end of file
+travis-ci = { repository = "Peternator7/strum" }
+
+[features]
+derive = ["strum_macros"]
diff --git a/strum/src/lib.rs b/strum/src/lib.rs
index f566afa..dd02217 100644
--- a/strum/src/lib.rs
+++ b/strum/src/lib.rs
@@ -206,3 +206,12 @@ where
 pub trait EnumCount {
     fn count() -> usize;
 }
+
+#[cfg(feature = "derive")]
+#[allow(unused_imports)]
+#[macro_use]
+extern crate strum_macros;
+
+#[cfg(feature = "derive")]
+#[doc(hidden)]
+pub use strum_macros::*;


Test patch:
diff --git a/strum_tests/Cargo.toml b/strum_tests/Cargo.toml
index 105ca71..aae5f2d 100644
--- a/strum_tests/Cargo.toml
+++ b/strum_tests/Cargo.toml
@@ -4,7 +4,7 @@ version = "0.15.0"
 authors = ["Peter Glotfelty <peglotfe@microsoft.com>"]
 
 [dependencies]
-strum = { path = "../strum" }
+strum = { path = "../strum", features = ["derive"] }
 strum_macros = { path = "../strum_macros", features = [] }
 clap = "2.33.0"
 structopt = "0.2.18"
diff --git a/strum_tests/src/lib.rs b/strum_tests/src/lib.rs
index ed73ccb..0d64650 100644
--- a/strum_tests/src/lib.rs
+++ b/strum_tests/src/lib.rs
@@ -1,6 +1,8 @@
+#![allow(unused_imports)]
 extern crate strum;
 #[macro_use]
 extern crate strum_macros;
+use strum::*;
 
 #[allow(dead_code)]
 #[derive(Debug, Eq, PartialEq, EnumString, ToString, EnumCount, EnumDiscriminants)]
diff --git a/strum_tests/tests/enum_message.rs b/strum_tests/tests/enum_message.rs
index 4e5415b..bcde8bf 100644
--- a/strum_tests/tests/enum_message.rs
+++ b/strum_tests/tests/enum_message.rs
@@ -1,3 +1,4 @@
+#![allow(unused_imports)]
 extern crate strum;
 #[macro_use]
 extern crate strum_macros;
diff --git a/strum_tests/tests/enum_props.rs b/strum_tests/tests/enum_props.rs
index 7af0aec..b9b9fc2 100644
--- a/strum_tests/tests/enum_props.rs
+++ b/strum_tests/tests/enum_props.rs
@@ -1,3 +1,4 @@
+#![allow(unused_imports)]
 extern crate strum;
 #[macro_use]
 extern crate strum_macros;