8个版本

0.3.4 2023年9月12日
0.3.3 2023年9月12日
0.3.2 2021年11月18日
0.3.1 2021年1月25日
0.1.1 2019年3月11日

#698过程宏

Download history · Rust 包仓库 25577/week @ 2024-03-14 · Rust 包仓库 39268/week @ 2024-03-21 · Rust 包仓库 37979/week @ 2024-03-28 · Rust 包仓库 37981/week @ 2024-04-04 · Rust 包仓库 40042/week @ 2024-04-11 · Rust 包仓库 39205/week @ 2024-04-18 · Rust 包仓库 46610/week @ 2024-04-25 · Rust 包仓库 53305/week @ 2024-05-02 · Rust 包仓库 51046/week @ 2024-05-09 · Rust 包仓库 51645/week @ 2024-05-16 · Rust 包仓库 39239/week @ 2024-05-23 · Rust 包仓库 35988/week @ 2024-05-30 · Rust 包仓库 36868/week @ 2024-06-06 · Rust 包仓库 42552/week @ 2024-06-13 · Rust 包仓库 42842/week @ 2024-06-20 · Rust 包仓库 38899/week @ 2024-06-27 · Rust 包仓库

167,117 每月下载次数
用于 32 个crates(通过 rav1e

MIT 许可证

13KB
169

模仿来自 claparg_enum! 的过程宏推导

Crates.io docs.rs dependency status

用法

Cargo.toml

[dependencies]
arg_enum_proc_macro = "0.3"

在rust代码中

use arg_enum_proc_macro::ArgEnum;

/// All the possible states of Foo
#[derive(ArgEnum)]
pub enum Foo {
    /// Initial state
    Unk,
    /// Foo is on
    On,
    /// Foo is off
    Off,
}

别名

可以使用属性 arg_enum(alias = "AliasVariant") 来表示别名。 FromStr 将 "AliasVariant" 字符串映射到装饰后的枚举变体

/// All the possible states of Foo
#[derive(ArgEnum)]
pub enum Foo {
    /// Initial state
    Unk,
    /// Foo is on
    #[arg_enum(alias = "Up")]
    On,
    /// Foo is off
    #[arg_enum(alias = "Down")]
    Off,
}

依赖关系

~280–730KB
~18K SLoC