Skip to content

Commit

Permalink
ToString is deprecated in favor of display. (#180)
Browse files Browse the repository at this point in the history
* ToString is deprecated in favor of display.

* Remove doc(hidden)

* Remove references to `ToString` macro

Co-authored-by: Peter Glotfelty <peter@glotfelty.us>
  • Loading branch information
Peternator7 and Peter Glotfelty committed Oct 9, 2021
1 parent 6119f10 commit 07f9fe3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 0 additions & 2 deletions README.md
Expand Up @@ -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

Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions strum/src/additional_attributes.rs
Expand Up @@ -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,
Expand Down Expand Up @@ -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>`.
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions strum_macros/src/lib.rs
Expand Up @@ -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);
Expand Down

0 comments on commit 07f9fe3

Please sign in to comment.