]> git.lizzy.rs Git - rust.git/blob - src/test/ui/associated-types/associated-types-in-fn.rs
Merge commit '4c41a222ca5d1325fb4b6709395bd06e766cc042' into clippyup
[rust.git] / src / test / ui / associated-types / associated-types-in-fn.rs
1 // run-pass
2
3 trait Get {
4     type Value;
5     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;
14     fn get(&self) -> &isize {
15         &self.x
16     }
17 }
18
19 fn grab<T:Get>(x: &T) -> &<T as Get>::Value {
20     x.get()
21 }
22
23 fn main() {
24     let s = Struct {
25         x: 100,
26     };
27     assert_eq!(*grab(&s), 100);
28 }