1
use serde::{Deserialize, Serialize};
2

            
3
20
#[derive(Debug, Deserialize, PartialEq, Serialize)]
4
#[serde(rename_all = "kebab-case")]
5
enum MyEnumWithDashes {
6
    ThisIsMyUnitVariant,
7
    ThisIsMyTupleVariant(bool, i32),
8
}
9

            
10
16
#[derive(Debug, Deserialize, PartialEq, Serialize)]
11
#[serde(rename_all = "kebab-case")]
12
struct MyStructWithDashes {
13
    my_enum: MyEnumWithDashes,
14
    #[serde(rename = "2nd")]
15
    my_enum2: MyEnumWithDashes,
16
    will_be_renamed: u32,
17
}
18

            
19
#[test]
20
4
fn roundtrip_ident_with_dash() {
21
4
    let value = MyStructWithDashes {
22
4
        my_enum: MyEnumWithDashes::ThisIsMyUnitVariant,
23
4
        my_enum2: MyEnumWithDashes::ThisIsMyTupleVariant(false, -3),
24
4
        will_be_renamed: 32,
25
4
    };
26
4

            
27
4
    let serial = ron::ser::to_string(&value).unwrap();
28
4

            
29
4
    println!("Serialized: {}", serial);
30
4

            
31
4
    let deserial = ron::de::from_str(&serial);
32
4

            
33
4
    assert_eq!(Ok(value), deserial);
34
4
}