xref: /DragonOS/kernel/crates/intertrait/tests/ui/unknown-flag.rs (revision 7c28051e8c601312d3d0fd7bcb71bc71450d10c0)
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 {
11     fn greet(&self);
12 }
13 
14 impl Greet for Data {
15     fn greet(&self) {
16         println!("Hello");
17     }
18 }
19 
20 impl Source for Data {}
21 
22 fn 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