Crates.io | serde-dot-case |
lib.rs | serde-dot-case |
version | 0.1.0 |
source | src |
created_at | 2024-05-13 16:32:16.101295 |
updated_at | 2024-05-13 16:32:16.101295 |
description | Rename all enum fields to dot.case |
homepage | |
repository | https://github.com/nitn3lav/serde-dot-case |
max_upload_size | |
id | 1238637 |
size | 14,953 |
Rename all enum fields to dot.case
.
use serde::{Deserialize, Serialize};
use serde_dot_case::serde_dot_case;
#[serde_dot_case]
#[derive(Debug, Deserialize, Serialize)]
enum MyEnum {
MyVariant,
}
#[test]
fn deserialize() {
assert!(matches!(
serde_json::from_str::<MyEnum>("\"my.variant\"").unwrap(),
MyEnum::MyVariant
));
}
#[test]
fn serialize() {
assert_eq!(
"\"my.variant\"",
serde_json::to_string(&MyEnum::MyVariant).unwrap(),
);
}