1 use intertrait::cast::*; 2 use intertrait::*; 3 4 struct Data; 5 6 trait Source: CastFrom {} 7 8 trait Greet { greet(&self)9 fn greet(&self); 10 } 11 12 #[cast_to] 13 impl Greet for Data { greet(&self)14 fn greet(&self) { 15 println!("Hello"); 16 } 17 } 18 19 impl Source for Data {} 20 21 #[test] test_cast_to_on_trait_impl()22fn test_cast_to_on_trait_impl() { 23 let data = Data; 24 let source: &dyn Source = &data; 25 let greet = source.cast::<dyn Greet>(); 26 greet.unwrap().greet(); 27 } 28