1 // run-pass
2 
3 trait Get {
4     type Value;
get(&self) -> &<Self as Get>::Value5     fn get(&self) -> &<Self as Get>::Value;
6 }
7 
8 struct Struct {
9     x: isize,
10 }
11 
12 impl Get for Struct {
13     type Value = isize;
get(&self) -> &isize14     fn get(&self) -> &isize {
15         &self.x
16     }
17 }
18 
19 trait Grab {
20     type U;
grab(&self) -> &<Self as Grab>::U21     fn grab(&self) -> &<Self as Grab>::U;
22 }
23 
24 impl<T:Get> Grab for T {
25     type U = <T as Get>::Value;
grab(&self) -> &<T as Get>::Value26     fn grab(&self) -> &<T as Get>::Value {
27         self.get()
28     }
29 }
30 
main()31 fn main() {
32     let s = Struct {
33         x: 100,
34     };
35     assert_eq!(*s.grab(), 100);
36 }
37