use jget_derive::Jget; #[derive(Debug, PartialEq, Eq, Jget)] pub struct SimpleStructExample { pub value: u16, } #[derive(Debug, PartialEq, Eq, Jget)] pub struct SimpleStructExample2 { pub value: u16, pub data: u16, #[jget(get)] pub other: String, } #[derive(Debug, PartialEq, Eq, Jget)] pub enum SimpleEnumExample { #[jget(get_option="value:Option")] V1(SimpleStructExample), #[jget(get_option="value:Option, data:Option, get_other():Option")] V2(SimpleStructExample2), } fn main() { let value = SimpleEnumExample::V2(SimpleStructExample2 { value: 1, data: 2, other: "123".to_string() }); assert_eq!(value.get_value(), Some(1)); assert_eq!(value.get_data(), Some(2)); assert_eq!(value.get_other(), Some("123".to_string())); let value = SimpleEnumExample::V1(SimpleStructExample { value: 1 }); assert_eq!(value.get_value(), Some(1)); }