Debian Codegraph @

.cargo/vendor/arg_enum_proc_macro/README.md

raw
1 # Procedural macro derive that mimics `arg_enum!` from [clap](https://clap.rs)
2
3 ![Crates.io](https://img.shields.io/crates/v/arg_enum_proc_macro)
4 ![docs.rs](https://docs.rs/mio/badge.svg)
5 [![dependency status](https://deps.rs/repo/github/lu-zero/arg_enum_proc_macro/status.svg)](https://deps.rs/repo/github/lu-zero/arg_enum_proc_macro)
6
7 ## Usage
8
9 In `Cargo.toml`:
10 ``` toml
11 [dependencies]
12 arg_enum_proc_macro = "0.3"
13 ```
14
15 In the rust code:
16 ``` rust
17 use arg_enum_proc_macro::ArgEnum;
18
19 /// All the possible states of Foo
20 #[derive(ArgEnum)]
21 pub enum Foo {
22 /// Initial state
23 Unk,
24 /// Foo is on
25 On,
26 /// Foo is off
27 Off,
28 }
29 ```
30
31 ### Aliases
32
33 It is possible to express an alias using the attribute `arg_enum(alias = "AliasVariant")`.
34 The `FromStr` will map the "AliasVariant" string to the decorated enum variant:
35
36 ``` rust
37 /// All the possible states of Foo
38 #[derive(ArgEnum)]
39 pub enum Foo {
40 /// Initial state
41 Unk,
42 /// Foo is on
43 #[arg_enum(alias = "Up")]
44 On,
45 /// Foo is off
46 #[arg_enum(alias = "Down")]
47 Off,
48 }
49 ```