1
use std::ops::Bound;
2

            
3
#[derive(serde::Deserialize, serde::Serialize, PartialEq, Eq, Debug)]
4
#[serde(untagged)]
5
enum EitherInterval<V> {
6
    B(Interval<V>),
7
    D(V, Option<V>),
8
}
9

            
10
type Interval<V> = (Bound<V>, Bound<V>);
11

            
12
#[test]
13
4
fn serde_roundtrip() {
14
4
    let interval = EitherInterval::B((Bound::Excluded(0u8), Bound::Unbounded));
15
4

            
16
4
    let ron: String = ron::ser::to_string(&interval).unwrap();
17
4
    assert_eq!(ron, "(Excluded(0),Unbounded)");
18

            
19
4
    let de = ron::de::from_str(&ron).unwrap();
20
4
    assert_eq!(interval, de);
21
4
}