|
3 | 3 | //! Strum is a set of macros and traits for working with |
4 | 4 | //! enums and strings easier in Rust. |
5 | 5 | //! |
| 6 | +//! This crate only contains derive macros for use with the |
| 7 | +//! [`strum`](https://docs.rs/strum) |
| 8 | +//! crate. The macros provied by this crate are also available by |
| 9 | +//! enabling the `derive` feature in aforementioned `strum` crate. |
6 | 10 |
|
7 | 11 | #![recursion_limit = "128"] |
8 | 12 |
|
@@ -367,14 +371,16 @@ pub fn to_string(input: proc_macro::TokenStream) -> proc_macro::TokenStream { |
367 | 371 | /// 3. The name of the variant will be used if there are no `serialize` or `to_string` attributes. |
368 | 372 | /// 4. If the enum has a `strum(prefix = "some_value_")`, every variant will have that prefix prepended |
369 | 373 | /// to the serialization. |
370 | | -/// 5. Enums with named fields support named field interpolation. The value will be interpolated into the output string. |
| 374 | +/// 5. Enums with fields support string interpolation. |
371 | 375 | /// Note this means the variant will not "round trip" if you then deserialize the string. |
372 | 376 | /// |
373 | 377 | /// ```rust |
374 | 378 | /// #[derive(strum_macros::Display)] |
375 | 379 | /// pub enum Color { |
376 | 380 | /// #[strum(to_string = "saturation is {sat}")] |
377 | 381 | /// Red { sat: usize }, |
| 382 | +/// #[strum(to_string = "hue is {1}, saturation is {0}")] |
| 383 | +/// Blue(usize, usize), |
378 | 384 | /// } |
379 | 385 | /// ``` |
380 | 386 | /// |
@@ -426,7 +432,7 @@ pub fn display(input: proc_macro::TokenStream) -> proc_macro::TokenStream { |
426 | 432 | /// Creates a new type that iterates of the variants of an enum. |
427 | 433 | /// |
428 | 434 | /// Iterate over the variants of an Enum. Any additional data on your variants will be set to `Default::default()`. |
429 | | -/// The macro implements `strum::IntoEnumIterator` on your enum and creates a new type called `YourEnumIter` that is the iterator object. |
| 435 | +/// The macro implements [`strum::IntoEnumIterator`](https://docs.rs/strum/latest/strum/trait.IntoEnumIterator.html) on your enum and creates a new type called `YourEnumIter` that is the iterator object. |
430 | 436 | /// You cannot derive `EnumIter` on any type with a lifetime bound (`<'a>`) because the iterator would surely |
431 | 437 | /// create [unbounded lifetimes](https://doc.rust-lang.org/nightly/nomicon/unbounded-lifetimes.html). |
432 | 438 | /// |
@@ -588,7 +594,7 @@ pub fn enum_table(input: proc_macro::TokenStream) -> proc_macro::TokenStream { |
588 | 594 | /// data. The discriminant follows the same rules as `rustc`. The first discriminant is zero and each |
589 | 595 | /// successive variant has a discriminant of one greater than the previous variant, except where an |
590 | 596 | /// explicit discriminant is specified. The type of the discriminant will match the `repr` type if |
591 | | -/// it is specifed. |
| 597 | +/// it is specified. |
592 | 598 | /// |
593 | 599 | /// When the macro is applied using rustc >= 1.46 and when there is no additional data on any of |
594 | 600 | /// the variants, the `from_repr` function is marked `const`. rustc >= 1.46 is required |
@@ -668,7 +674,7 @@ pub fn from_repr(input: proc_macro::TokenStream) -> proc_macro::TokenStream { |
668 | 674 | /// |
669 | 675 | /// Encode strings into the enum itself. The `strum_macros::EmumMessage` macro implements the `strum::EnumMessage` trait. |
670 | 676 | /// `EnumMessage` looks for `#[strum(message="...")]` attributes on your variants. |
671 | | -/// You can also provided a `detailed_message="..."` attribute to create a seperate more detailed message than the first. |
| 677 | +/// You can also provided a `detailed_message="..."` attribute to create a separate more detailed message than the first. |
672 | 678 | /// |
673 | 679 | /// `EnumMessage` also exposes the variants doc comments through `get_documentation()`. This is useful in some scenarios, |
674 | 680 | /// but `get_message` should generally be preferred. Rust doc comments are intended for developer facing documentation, |
@@ -754,7 +760,7 @@ pub fn enum_messages(input: proc_macro::TokenStream) -> proc_macro::TokenStream |
754 | 760 |
|
755 | 761 | /// Add custom properties to enum variants. |
756 | 762 | /// |
757 | | -/// Enables the encoding of arbitary constants into enum variants. This method |
| 763 | +/// Enables the encoding of arbitrary constants into enum variants. This method |
758 | 764 | /// currently only supports adding additional string values. Other types of literals are still |
759 | 765 | /// experimental in the rustc compiler. The generated code works by nesting match statements. |
760 | 766 | /// The first match statement matches on the type of the enum, and the inner match statement |
|
0 commit comments