| Name | Date | Size | #Lines | LOC | ||
|---|---|---|---|---|---|---|
| .. | - | - | ||||
| src/ | 04-Jul-2025 | - | 3,900 | 2,642 | ||
| .android-checksum.json | D | 04-Jul-2025 | 3 KiB | 1 | 1 | |
| .cargo-checksum.json | D | 04-Jul-2025 | 2.6 KiB | 1 | 1 | |
| Android.bp | D | 04-Jul-2025 | 1.3 KiB | 53 | 48 | |
| Cargo.toml | D | 04-Jul-2025 | 1.3 KiB | 56 | 47 | |
| LICENSE | D | 04-Jul-2025 | 1 KiB | 22 | 17 | |
| METADATA | D | 04-Jul-2025 | 408 | 18 | 17 | |
| MODULE_LICENSE_MIT | D | 04-Jul-2025 | 0 | |||
| README.md | D | 04-Jul-2025 | 4.6 KiB | 89 | 68 | |
| TEST_MAPPING | D | 04-Jul-2025 | 80 | 8 | 7 | |
| cargo_embargo.json | D | 04-Jul-2025 | 148 | 10 | 10 |
README.md
1# Strum 2 3[](https://travis-ci.com/Peternator7/strum) 4[](https://ci.appveyor.com/project/Peternator7/strum) 5[](https://crates.io/crates/strum) 6[](https://docs.rs/strum) 7 8 9 10Strum is a set of macros and traits for working with enums and strings easier in Rust. 11 12# Compatibility 13 14Strum is currently compatible with versions of rustc >= 1.66.1. Pull Requests that improve compatibility with older 15versions are welcome. The project goal is to support a rust version for at least 2 years after release 16and even longer is preferred since this project changes slowly. 17 18# Including Strum in Your Project 19 20Import strum and strum_macros into your project by adding the following lines to your 21Cargo.toml. Strum_macros contains the macros needed to derive all the traits in Strum. 22 23```toml 24[dependencies] 25strum = "0.27" 26strum_macros = "0.27" 27 28# You can also use the "derive" feature, and import the macros directly from "strum" 29# strum = { version = "0.27", features = ["derive"] } 30``` 31 32# Strum Macros 33 34Strum has implemented the following macros: 35 36| Macro | Description | 37| --- | ----------- | 38| [EnumString] | Converts strings to enum variants based on their name. | 39| [Display] | Converts enum variants to strings | 40| [FromRepr] | Convert from an integer to an enum. | 41| [AsRefStr] | Implement `AsRef<str>` for `MyEnum` | 42| [IntoStaticStr] | Implements `From<MyEnum> for &'static str` on an enum | 43| [EnumIter] | Creates a new type that iterates of the variants of an enum. | 44| [EnumProperty] | Add custom properties to enum variants. | 45| [EnumMessage] | Add a verbose message to an enum variant. | 46| [EnumDiscriminants] | Generate a new type with only the discriminant names. | 47| [EnumCount] | Add a constant `usize` equal to the number of variants. | 48| [VariantArray] | Adds an associated `VARIANTS` constant which is an array of all enum discriminants | 49| [VariantNames] | Adds an associated `VARIANTS` constant which is an array of discriminant names | 50| [EnumTable] | *Experimental*, creates a new type that stores an item of a specified type for each variant of the enum. | 51 52# Contributing 53 54Thanks for your interest in contributing. Bug fixes are always welcome. If you are interested in implementing or 55adding a macro, please open an issue first to discuss the feature. I have limited bandwidth to review new features. 56 57The project is divided into 3 parts, the traits are in the 58`/strum` folder. The procedural macros are in the `/strum_macros` folder, and the integration tests are 59in `/strum_tests`. If you are adding additional features to `strum` or `strum_macros`, you should make sure 60to run the tests and add new integration tests to make sure the features work as expected. 61 62# Debugging 63 64To see the generated code, set the STRUM_DEBUG environment variable before compiling your code. 65`STRUM_DEBUG=1` will dump all of the generated code for every type. `STRUM_DEBUG=YourType` will 66only dump the code generated on a type named `YourType`. 67 68# Name 69 70Strum is short for STRing enUM because it's a library for augmenting enums with additional 71information through strings. 72 73Strumming is also a very whimsical motion, much like writing Rust code. 74 75[EnumString]: https://docs.rs/strum_macros/latest/strum_macros/derive.EnumString.html 76[Display]: https://docs.rs/strum_macros/latest/strum_macros/derive.Display.html 77[AsRefStr]: https://docs.rs/strum_macros/latest/strum_macros/derive.AsRefStr.html 78[IntoStaticStr]: https://docs.rs/strum_macros/latest/strum_macros/derive.IntoStaticStr.html 79[EnumIter]: https://docs.rs/strum_macros/latest/strum_macros/derive.EnumIter.html 80[EnumIs]: https://docs.rs/strum_macros/latest/strum_macros/derive.EnumIs.html 81[EnumProperty]: https://docs.rs/strum_macros/latest/strum_macros/derive.EnumProperty.html 82[EnumMessage]: https://docs.rs/strum_macros/latest/strum_macros/derive.EnumMessage.html 83[EnumDiscriminants]: https://docs.rs/strum_macros/latest/strum_macros/derive.EnumDiscriminants.html 84[EnumCount]: https://docs.rs/strum_macros/latest/strum_macros/derive.EnumCount.html 85[FromRepr]: https://docs.rs/strum_macros/latest/strum_macros/derive.FromRepr.html 86[VariantArray]: https://docs.rs/strum_macros/latest/strum_macros/derive.VariantArray.html 87[VariantNames]: https://docs.rs/strum_macros/latest/strum_macros/derive.VariantNames.html 88[EnumTable]: https://docs.rs/strum_macros/latest/strum_macros/derive.EnumTable.html 89