Skip to content

Commit

Permalink
Added docs about From impls.
Browse files Browse the repository at this point in the history
  • Loading branch information
azriel91 committed Sep 24, 2018
1 parent 91b9018 commit 44087a9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion README.md
Expand Up @@ -299,7 +299,7 @@ Strum has implemented the following macros:
7. `EnumDiscriminants`: 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 followign derives:
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.

Expand Down Expand Up @@ -357,6 +357,13 @@ Strum has implemented the following macros:
}
```

The derived enum also has the following trait implementations:

* `impl From<MyEnum> for MyEnumDiscriminants`
* `impl<'_enum> From<&'_enum MyEnum> for MyEnumDiscriminants`

These allow you to get the *Discriminants* enum variant from the original enum.

# Additional Attributes

Strum supports several custom attributes to modify the generated code. At the enum level, the
Expand Down
9 changes: 8 additions & 1 deletion strum/src/lib.rs
Expand Up @@ -293,7 +293,7 @@
//! 7. `EnumDiscriminants`: 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 followign derives:
//! 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.
//!
Expand Down Expand Up @@ -350,6 +350,13 @@
//! }
//! ```
//!
//! The derived enum also has the following trait implementations:
//!
//! * `impl From<MyEnum> for MyEnumDiscriminants`
//! * `impl<'_enum> From<&'_enum MyEnum> for MyEnumDiscriminants`
//!
//! These allow you to get the *Discriminants* enum variant from the original enum.
//!
//! # Additional Attributes
//!
//! Strum supports several custom attributes to modify the generated code. At the enum level, the
Expand Down

0 comments on commit 44087a9

Please sign in to comment.