use invade::invade; #[derive(Debug)] #[invade] struct Counter { count: u32, title: String, } #[invade] impl Counter { fn new() -> Counter { Counter { count: 69, title: "Counter".to_string(), } } pub fn inc(&mut self) { self.count += 1; } pub fn dec(&mut self) { self.count -= 1; } pub fn inc_by(&mut self, n: u32) { self.count += n; } } fn main() { let mut counter = Counter::new(); println!("count: {:?}", counter.invade().get::("count")); println!("count: {:?}", counter.invade_get::("count")); counter.invade().set("count", 42_u32); counter.invade_set("count", 42_u32); println!("count: {:?}", counter.invade_get::("count")); counter.invade_call("inc", vec![]); counter.invade_call("inc", vec![]); counter.invade_call("dec", vec![]); counter.invade_call("inc", vec![]); counter.invade_call("inc_by", vec![Box::new(5_u32)]); println!("count: {}", counter.count); println!("title: {:?}", counter.invade_get::("title")); }