1
use ron::{de::from_str, ser::to_string};
2
use serde::{Deserialize, Serialize};
3

            
4
12
#[derive(Debug, PartialEq, Serialize, Deserialize)]
5
#[serde(tag = "type", content = "data")]
6
enum TestEnum {
7
    Name(String),
8
    Index(u32),
9
}
10

            
11
#[test]
12
4
fn test_adjacently_tagged() {
13
4
    let source = TestEnum::Index(1);
14
4

            
15
4
    let ron_string = to_string(&source).unwrap();
16
4

            
17
4
    assert_eq!(ron_string, "(type:Index,data:1)");
18

            
19
4
    let deserialized = from_str::<TestEnum>(&ron_string).unwrap();
20
4

            
21
4
    assert_eq!(deserialized, source);
22
4
}