Debian Codegraph @

tests/530_untagged_union.rs

raw symbols SCIP
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 fn serde_roundtrip() {
14 let interval = EitherInterval::B((Bound::Excluded(0u8), Bound::Unbounded));
15
16 let ron: String = ron::ser::to_string(&interval).unwrap();
17 assert_eq!(ron, "(Excluded(0),Unbounded)");
18
19 let de = ron::de::from_str(&ron).unwrap();
20 assert_eq!(interval, de);
21 }