15 releases (breaking)

0.15.0 Mar 27, 2019
0.13.0 Dec 24, 2018
0.11.0 Sep 26, 2018
0.10.0 Jun 23, 2018
0.5.1 Feb 25, 2017

#7 in Procedural macro helpers

Download history 8149/week @ 2019-01-21 8912/week @ 2019-01-28 11347/week @ 2019-02-04 10784/week @ 2019-02-11 9669/week @ 2019-02-18 10369/week @ 2019-02-25 9417/week @ 2019-03-04 9878/week @ 2019-03-11 9184/week @ 2019-03-18 10390/week @ 2019-03-25 10261/week @ 2019-04-01 12707/week @ 2019-04-08 10739/week @ 2019-04-15 11359/week @ 2019-04-22 13100/week @ 2019-04-29

54,312 downloads per month
Used in 69 crates (44 directly)

MIT license

9KB


lib.rs:

Strum

Build Status Latest Version Rust Documentation

Strum is a set of macros and traits for working with enums and strings easier in Rust.

The full version of the README can be found on Github.

Including Strum in Your Project

Import strum and strum_macros into your project by adding the following lines to your Cargo.toml. Strum_macros contains the macros needed to derive all the traits in Strum.

[dependencies]
strum = "0.15.0"
strum_macros = "0.15.0"

And add these lines to the root of your project, either lib.rs or main.rs.

// Strum contains all the trait definitions
extern crate strum;
#[macro_use]
extern crate strum_macros;
# fn main() {}

Strum Macros

Strum has implemented the following macros:

Macro Description
EnumString Converts strings to enum variants based on their name
Display Converts enum variants to strings
AsRefStr Converts enum variants to &'static str
IntoStaticStr Implements From<MyEnum> for &'static str on an enum
EnumIter Creates a new type that iterates of the variants of an enum.
EnumProperty Add custom properties to enum variants.
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 variantes.

No runtime deps