1个不稳定版本
0.1.0 | 2023年10月11日 |
---|
1533 在 过程宏
3KB
enum_all_variants
使用serde_json生成枚举的impl Display的过程宏
示例
use enum_to_string::ToJsonString;
use serde::Serialize;
#[derive(Debug, Serialize, ToJsonString)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
enum Direction {
Left,
Top,
Right,
Bottom,
}
fn main() {
println!("{}", Direction::Left.to_string());
}
输出
LEFT
依赖
~0.6–1.4MB
~32K SLoC