mirror of
https://github.com/danog/strum.git
synced 2024-11-26 12:04:38 +01:00
Merge branch 'master' into peternator7/update-serialize-all
This commit is contained in:
commit
c00b2f4fc1
@ -45,7 +45,6 @@ Strum has implemented the following macros:
|
||||
| [EnumMessage] | Add a verbose message to an enum variant. |
|
||||
| [EnumDiscriminants] | Generate a new type with only the discriminant names. |
|
||||
| [EnumCount] | Add a constant `usize` equal to the number of variants. |
|
||||
| [ToString] | Serialize an enum to a String. |
|
||||
|
||||
# Contributing
|
||||
|
||||
@ -78,4 +77,3 @@ Strumming is also a very whimsical motion, much like writing Rust code.
|
||||
[EnumMessage]: https://docs.rs/strum_macros/0.21/strum_macros/derive.EnumMessage.html
|
||||
[EnumDiscriminants]: https://docs.rs/strum_macros/0.21/strum_macros/derive.EnumDiscriminants.html
|
||||
[EnumCount]: https://docs.rs/strum_macros/0.21/strum_macros/derive.EnumCount.html
|
||||
[ToString]: https://docs.rs/strum_macros/0.21/strum_macros/derive.ToString.html
|
||||
|
@ -59,7 +59,7 @@
|
||||
//! be applied multiple times to an element and the enum variant will be parsed if any of them match.
|
||||
//!
|
||||
//! - `to_string="..."`: Similar to `serialize`. This value will be included when using `FromStr()`. More importantly,
|
||||
//! this specifies what text to use when calling `variant.to_string()` with the `ToString` derivation, or when calling `variant.as_ref()` with `AsRefStr`.
|
||||
//! this specifies what text to use when calling `variant.to_string()` with the `Display` derivation, or when calling `variant.as_ref()` with `AsRefStr`.
|
||||
//!
|
||||
//! - `default`: Applied to a single variant of an enum. The variant must be a Tuple-like
|
||||
//! variant with a single piece of data that can be create from a `&str` i.e. `T: From<&str>`.
|
||||
@ -79,7 +79,7 @@
|
||||
//!
|
||||
//! - `ascii_case_insensitive`: makes the comparison to this variant case insensitive (ASCII only).
|
||||
//! If the whole enum is marked `ascii_case_insensitive`, you can specify `ascii_case_insensitive = false`
|
||||
//! to disable case insensitivity on this variant.
|
||||
//! to disable case insensitivity on this v ariant.
|
||||
//!
|
||||
//! - `message=".."`: Adds a message to enum variant. This is used in conjunction with the `EnumMessage`
|
||||
//! trait to associate a message with a variant. If `detailed_message` is not provided,
|
||||
|
@ -271,6 +271,7 @@ pub fn into_static_str(input: proc_macro::TokenStream) -> proc_macro::TokenStrea
|
||||
/// let yellow = Color::Yellow;
|
||||
/// assert_eq!(String::from("Yellow"), yellow.to_string());
|
||||
/// ```
|
||||
#[deprecated(since="0.22.0", note="please use `#[derive(Display)]` instead. See issue https://github.com/Peternator7/strum/issues/132")]
|
||||
#[proc_macro_derive(ToString, attributes(strum))]
|
||||
pub fn to_string(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
||||
let ast = syn::parse_macro_input!(input as DeriveInput);
|
||||
|
Loading…
Reference in New Issue
Block a user