diff --git a/.travis.yml b/.travis.yml index 4496d31..71eafa8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ rust: - stable - beta - nightly - - 1.31.1 + - 1.32.0 matrix: allow_failures: - rust: nightly diff --git a/README.md b/README.md index fd2c764..d1ca88e 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,9 @@ Strum is a set of macros and traits for working with enums and strings easier in # Compatibility -Strum is compatible with versions of rustc >= 1.31.0. That's the earliest version of stable rust that supports -impl trait. Pull Requests that improve compatibility with older versions are welcome, but new feature work -will focus on the current version of rust with an effort to avoid breaking compatibility with older versions. +Strum is compatible with versions of rustc >= 1.32.0. Pull Requests that improve compatibility with older +versions are welcome, but new feature work will focus on the current version of rust with an effort to +avoid breaking compatibility with older versions. # Including Strum in Your Project diff --git a/appveyor.yml b/appveyor.yml index c5ca7e9..2d57a80 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -38,10 +38,10 @@ environment: ### MSVC Toolchains ### # MSRC 64-bit MSVC - - channel: 1.31.1 + - channel: 1.32.0 target: x86_64-pc-windows-msvc # MSRC 32-bit MSVC - - channel: 1.31.1 + - channel: 1.32.0 target: i686-pc-windows-msvc # Stable 64-bit MSVC - channel: stable @@ -67,10 +67,10 @@ environment: ### GNU Toolchains ### # MSRC 64-bit GNU - - channel: 1.31.1 + - channel: 1.32.0 target: x86_64-pc-windows-gnu # MSRC 32-bit GNU - - channel: 1.31.1 + - channel: 1.32.0 target: i686-pc-windows-gnu # Stable 64-bit GNU - channel: stable diff --git a/strum_macros/src/lib.rs b/strum_macros/src/lib.rs index d777903..6383067 100644 --- a/strum_macros/src/lib.rs +++ b/strum_macros/src/lib.rs @@ -492,11 +492,15 @@ pub fn enum_properties(input: proc_macro::TokenStream) -> proc_macro::TokenStrea /// Generate a new type with only the discriminant names. /// -/// Given an enum named `MyEnum`, generates another enum called `MyEnumDiscriminants` with the same variants, without any data fields. -/// This is useful when you wish to determine the variant of an enum from a String, but the variants contain any -/// non-`Default` fields. By default, the generated enum has the following derives: -/// `Clone, Copy, Debug, PartialEq, Eq`. You can add additional derives using the -/// `#[strum_discriminants(derive(AdditionalDerive))]` attribute. +/// Given an enum named `MyEnum`, generates another enum called `MyEnumDiscriminants` with the same +/// variants but without any data fields. This is useful when you wish to determine the variant of +/// an `enum` but one or more of the variants contains a non-`Default` field. `From` +/// implementations are generated so that you can easily convert from `MyEnum` to +/// `MyEnumDiscriminants`. +/// +/// By default, the generated enum has the following derives: `Clone, Copy, Debug, PartialEq, Eq`. +/// You can add additional derives using the `#[strum_discriminants(derive(AdditionalDerive))]` +/// attribute. /// /// ``` /// // Bring trait into scope @@ -536,6 +540,17 @@ pub fn enum_properties(input: proc_macro::TokenStream) -> proc_macro::TokenStrea /// vec![MyVariants::Variant0, MyVariants::Variant1], /// MyVariants::iter().collect::>() /// ); +/// +/// // Make use of the auto-From conversion to check whether an instance of `MyEnum` matches a +/// // `MyEnumDiscriminants` discriminant. +/// assert_eq!( +/// MyEnumDiscriminants::Variant0, +/// MyEnum::Variant0(NonDefault).into() +/// ); +/// assert_eq!( +/// MyEnumDiscriminants::Variant0, +/// MyEnumDiscriminants::from(MyEnum::Variant0(NonDefault)) +/// ); /// ``` /// /// It is also possible to specify the visibility (e.g. `pub`/`pub(crate)`/etc.)