1 use serde_derive::Serialize; 2 3 #[derive(Serialize)] 4 struct S { 5 #[serde(getter = "S::get")] 6 a: u8, 7 } 8 9 impl S { get(&self) -> u810 fn get(&self) -> u8 { 11 self.a 12 } 13 } 14 main()15 fn main() {} 16