Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ToString is deprecated in favor of display. #180

Merged
merged 3 commits into from
Oct 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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