#枚举 #常量

无 std 相关联

一个将枚举变体与常量关联的特质

2 个不稳定版本

0.2.0 2021 年 11 月 13 日
0.1.0 2021 年 11 月 12 日

#335无标准库


razer_driver_rs 中使用

MIT 许可证

4KB

相关联

一个将枚举变体与常量关联的特质。有关自动推导此特质的说明,请参阅 associated-derive

通过启用 "derive" 功能来启用推导支持。

示例

#[derive(Associated)]
#[associated(Type = &'static str)]
enum Phonetic {
    #[assoc_const("Alpha")] Alpha,
    #[assoc(&"Bravo")] // #[assoc] requires an expression of type &'static Type
    Bravo = 3 // supports explicit enum discriminants
    // ...
}

Phonetic::Alpha.get_associated() // returns a static lifetime reference to "Alpha"

lib.rs:

一个将枚举变体与常量关联的特质。有关自动推导此特质的说明,请参阅 associated-derive

通过启用 "derive" 功能来启用推导支持。

依赖关系

~220KB