1 // check-pass
2 
3 trait Mirror {
4     type Other;
5 }
6 
7 #[derive(Debug)]
8 struct Even(usize);
9 struct Odd;
10 
11 impl Mirror for Even {
12     type Other = Odd;
13 }
14 
15 impl Mirror for Odd {
16     type Other = Even;
17 }
18 
19 trait Dyn<T: Mirror>: AsRef<<T as Mirror>::Other> {}
20 
21 impl Dyn<Odd> for Even {}
22 
23 impl AsRef<Even> for Even {
24     fn as_ref(&self) -> &Even {
25         self
26     }
27 }
28 
29 fn code<T: Mirror>(d: &dyn Dyn<T>) -> &T::Other {
30     d.as_ref()
31 }
32 
33 fn main() {
34     println!("{:?}", code(&Even(22)));
35 }
36