mirror of
https://github.com/danog/strum.git
synced 2024-11-26 20:14:40 +01:00
Update documentation to include listing all the supported case styles.
This commit is contained in:
parent
6119f107e2
commit
201d794fd6
@ -1,8 +1,22 @@
|
||||
//! # Documentation for Additional Attributes
|
||||
//!
|
||||
//! Strum supports several custom attributes to modify the generated code. At the enum level, the
|
||||
//! `#[strum(serialize_all = "snake_case")]` attribute can be used to change the case used when
|
||||
//! serializing to and deserializing from strings:
|
||||
//! ## Attributes on Enums
|
||||
//!
|
||||
//! Strum supports several custom attributes to modify the generated code. At the enum level, the following attributes are supported:
|
||||
//!
|
||||
//! - `#[strum(serialize_all = "case_style")]` attribute can be used to change the case used when serializing to and deserializing
|
||||
//! from strings. This feature is enabled by [withoutboats/heck](https://github.com/withoutboats/heck) and supported case styles are:
|
||||
//!
|
||||
//! - `camelCase`
|
||||
//! - `PascalCase`
|
||||
//! - `kebab-case`
|
||||
//! - `snake_case`
|
||||
//! - `SCREAMING_SNAKE_CASE`
|
||||
//! - `SCREAMING-KEBAB-CASE`
|
||||
//! - `lowercase`
|
||||
//! - `UPPERCASE`
|
||||
//! - `title_case`
|
||||
//! - `mixed_case`
|
||||
//!
|
||||
//! ```rust
|
||||
//! use std::string::ToString;
|
||||
@ -34,9 +48,11 @@
|
||||
//! );
|
||||
//! ```
|
||||
//!
|
||||
//! You can also apply the `#[strum(ascii_case_insensitive)]` attribute to the enum,
|
||||
//! - You can also apply the `#[strum(ascii_case_insensitive)]` attribute to the enum,
|
||||
//! and this has the same effect of applying it to every variant.
|
||||
//!
|
||||
//! ## Attributes on Variants
|
||||
//!
|
||||
//! Custom attributes are applied to a variant by adding `#[strum(parameter="value")]` to the variant.
|
||||
//!
|
||||
//! - `serialize="..."`: Changes the text that `FromStr()` looks for when parsing a string. This attribute can
|
||||
|
Loading…
Reference in New Issue
Block a user