use std::ops::Bound; #[derive(serde::Deserialize, serde::Serialize, PartialEq, Eq, Debug)] #[serde(untagged)] enum EitherInterval { B(Interval), D(V, Option), } type Interval = (Bound, Bound); #[test] fn serde_roundtrip() { let interval = EitherInterval::B((Bound::Excluded(0u8), Bound::Unbounded)); let ron: String = ron::ser::to_string(&interval).unwrap(); assert_eq!(ron, "(Excluded(0),Unbounded)"); let de = ron::de::from_str(&ron).unwrap(); assert_eq!(interval, de); }