From 5b20a3ed2c48f87741e2c29a5b9f8092a82655c0 Mon Sep 17 00:00:00 2001 From: Peter Glotfelty Date: Fri, 8 Oct 2021 15:50:59 -0700 Subject: [PATCH 1/3] ToString is deprecated in favor of display. --- strum_macros/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/strum_macros/src/lib.rs b/strum_macros/src/lib.rs index b49da1e6..155dd0ea 100644 --- a/strum_macros/src/lib.rs +++ b/strum_macros/src/lib.rs @@ -271,7 +271,9 @@ 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))] +#[doc(hidden)] pub fn to_string(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let ast = syn::parse_macro_input!(input as DeriveInput); From 25cfe27ce49a448d2a0b54c318e89f928cd8338d Mon Sep 17 00:00:00 2001 From: Peter Glotfelty Date: Fri, 8 Oct 2021 16:04:51 -0700 Subject: [PATCH 2/3] Remove doc(hidden) --- strum_macros/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/strum_macros/src/lib.rs b/strum_macros/src/lib.rs index 155dd0ea..a9805db3 100644 --- a/strum_macros/src/lib.rs +++ b/strum_macros/src/lib.rs @@ -273,7 +273,6 @@ pub fn into_static_str(input: proc_macro::TokenStream) -> proc_macro::TokenStrea /// ``` #[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))] -#[doc(hidden)] pub fn to_string(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let ast = syn::parse_macro_input!(input as DeriveInput); From 0492ad6bba435bf34bdcc44acdd073ec293978df Mon Sep 17 00:00:00 2001 From: Peter Glotfelty Date: Fri, 8 Oct 2021 16:49:27 -0700 Subject: [PATCH 3/3] Remove references to `ToString` macro --- README.md | 2 -- strum/src/additional_attributes.rs | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 80019df2..331ccd46 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/strum/src/additional_attributes.rs b/strum/src/additional_attributes.rs index e3d86ebd..8172a90f 100644 --- a/strum/src/additional_attributes.rs +++ b/strum/src/additional_attributes.rs @@ -9,7 +9,7 @@ //! use strum; //! use strum_macros; //! -//! #[derive(Debug, Eq, PartialEq, strum_macros::ToString)] +//! #[derive(Debug, Eq, PartialEq, strum_macros::Display)] //! #[strum(serialize_all = "snake_case")] //! enum Brightness { //! DarkBlack, @@ -43,7 +43,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>`. @@ -63,7 +63,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,