1
0
mirror of https://github.com/danog/strum.git synced 2024-11-30 04:28:59 +01:00

Merge branch 'master' of https://github.com/Peternator7/strum into peternator7/deprecate-renames

This commit is contained in:
Peter Glotfelty 2021-03-06 10:22:45 -08:00
commit 67d7119237
4 changed files with 28 additions and 13 deletions

View File

@ -3,7 +3,7 @@ rust:
- stable - stable
- beta - beta
- nightly - nightly
- 1.31.1 - 1.32.0
matrix: matrix:
allow_failures: allow_failures:
- rust: nightly - rust: nightly

View File

@ -11,9 +11,9 @@ Strum is a set of macros and traits for working with enums and strings easier in
# Compatibility # Compatibility
Strum is compatible with versions of rustc >= 1.31.0. That's the earliest version of stable rust that supports Strum is compatible with versions of rustc >= 1.32.0. Pull Requests that improve compatibility with older
impl trait. Pull Requests that improve compatibility with older versions are welcome, but new feature work versions are welcome, but new feature work will focus on the current version of rust with an effort to
will focus on the current version of rust with an effort to avoid breaking compatibility with older versions. avoid breaking compatibility with older versions.
# Including Strum in Your Project # Including Strum in Your Project

View File

@ -38,10 +38,10 @@ environment:
### MSVC Toolchains ### ### MSVC Toolchains ###
# MSRC 64-bit MSVC # MSRC 64-bit MSVC
- channel: 1.31.1 - channel: 1.32.0
target: x86_64-pc-windows-msvc target: x86_64-pc-windows-msvc
# MSRC 32-bit MSVC # MSRC 32-bit MSVC
- channel: 1.31.1 - channel: 1.32.0
target: i686-pc-windows-msvc target: i686-pc-windows-msvc
# Stable 64-bit MSVC # Stable 64-bit MSVC
- channel: stable - channel: stable
@ -67,10 +67,10 @@ environment:
### GNU Toolchains ### ### GNU Toolchains ###
# MSRC 64-bit GNU # MSRC 64-bit GNU
- channel: 1.31.1 - channel: 1.32.0
target: x86_64-pc-windows-gnu target: x86_64-pc-windows-gnu
# MSRC 32-bit GNU # MSRC 32-bit GNU
- channel: 1.31.1 - channel: 1.32.0
target: i686-pc-windows-gnu target: i686-pc-windows-gnu
# Stable 64-bit GNU # Stable 64-bit GNU
- channel: stable - channel: stable

View File

@ -492,11 +492,15 @@ pub fn enum_properties(input: proc_macro::TokenStream) -> proc_macro::TokenStrea
/// Generate a new type with only the discriminant names. /// 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. /// Given an enum named `MyEnum`, generates another enum called `MyEnumDiscriminants` with the same
/// This is useful when you wish to determine the variant of an enum from a String, but the variants contain any /// variants but without any data fields. This is useful when you wish to determine the variant of
/// non-`Default` fields. By default, the generated enum has the following derives: /// an `enum` but one or more of the variants contains a non-`Default` field. `From`
/// `Clone, Copy, Debug, PartialEq, Eq`. You can add additional derives using the /// implementations are generated so that you can easily convert from `MyEnum` to
/// `#[strum_discriminants(derive(AdditionalDerive))]` attribute. /// `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 /// // Bring trait into scope
@ -536,6 +540,17 @@ pub fn enum_properties(input: proc_macro::TokenStream) -> proc_macro::TokenStrea
/// vec![MyVariants::Variant0, MyVariants::Variant1], /// vec![MyVariants::Variant0, MyVariants::Variant1],
/// MyVariants::iter().collect::<Vec<_>>() /// MyVariants::iter().collect::<Vec<_>>()
/// ); /// );
///
/// // 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.) /// It is also possible to specify the visibility (e.g. `pub`/`pub(crate)`/etc.)