1 use intertrait::cast::*; 2 use intertrait::*; 3 use std::sync::Arc; 4 5 #[cast_to([sync, send] Greet)] 6 struct Data; 7 8 trait Source: CastFromSync {} 9 10 trait Greet { greet(&self)11 fn greet(&self); 12 } 13 14 impl Greet for Data { greet(&self)15 fn greet(&self) { 16 println!("Hello"); 17 } 18 } 19 20 impl Source for Data {} 21 main()22fn main() { 23 let data = Arc::new(Data); 24 let source: Arc<dyn Source> = data; 25 let greet = source.cast::<dyn Greet>(); 26 greet.unwrap_or_else(|_| panic!("can't happen")).greet(); 27 } 28