2 个版本
0.3.1 | 2020 年 7 月 13 日 |
---|---|
0.3.0 | 2020 年 7 月 13 日 |
0.2.1 |
|
0.1.5 |
|
170 在 无标准库 中
每月 27 次下载
32KB
572 行
Encap_Enum
Encap_Enum 为定义枚举、位标志和常量组提供 encap_enum!
宏。
用法
将此添加到您的 Cargo.toml
[dependencies]
encap_enum = "0.3.1"
并将此添加到您的 crate 根目录
#[macro_use]
extern crate encap_enum;
功能
- 迭代器。
- 位标志。
- 封装的标志值。
- 更改
enum
的可见性,包括内部值和枚举本身。
- 更改
- 支持任意数量的属性。
- 这包括文档注释,
#[repr(C)]
、#[derive]
和许多其他属性。
- 这包括文档注释,
- 无 std 依赖。
- FFI 兼容。
示例
encap_enum!{
/// ClassStyle is a structure used in the Window class.
#[repr(C)]
pub enum ClassStyle: pub u32 {
ByteAlignClient = 0x0000_1000,
ByteAlignWindow = 0x0000_2000, /// Aligns window on a byte boundary.
DoubleClicks = 0x0000_0008,
DropShadow = 0x0002_0000,
GlobalClass = 0x0000_4000,
// ...
}
}
fn main() {
println!("ByteAlignClient integer representation: {}", ClassStyle::ByteAlignClient.raw);
println!("ByteAlignClient debug representation: {:?}", ClassStyle::ByteAlignClient);
}
许可证
encap_enum
在 MIT 许可证 下授权。
最近更改
- 修复了错误的文档。