1 use intertrait::cast::*; 2 use intertrait::*; 3 4 struct Data; 5 6 trait Source: CastFrom {} 7 8 trait Greet { 9 fn greet(&self); 10 } 11 12 #[cast_to] 13 impl Greet for Data { 14 fn greet(&self) { 15 println!("Hello"); 16 } 17 } 18 19 impl Source for Data {} 20 21 #[test] 22 fn 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