mirror of
https://github.com/danog/strum.git
synced 2024-11-29 20:18:58 +01:00
Merge branch 'master' of https://github.com/Peternator7/strum into peternator7/deprecate-renames
This commit is contained in:
commit
67d7119237
@ -3,7 +3,7 @@ rust:
|
||||
- stable
|
||||
- beta
|
||||
- nightly
|
||||
- 1.31.1
|
||||
- 1.32.0
|
||||
matrix:
|
||||
allow_failures:
|
||||
- rust: nightly
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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::<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.)
|
||||
|
Loading…
Reference in New Issue
Block a user