]> git.lizzy.rs Git - rust.git/blob - tests/ui/associated-types/associated-types-in-default-method.rs
Rollup merge of #107306 - compiler-errors:correct-sugg-for-closure-arg-needs-borrow...
[rust.git] / tests / ui / associated-types / associated-types-in-default-method.rs
1 // run-pass
2
3 trait Get {
4     type Value;
5     fn get(&self) -> &<Self as Get>::Value;
6     fn grab(&self) -> &<Self as Get>::Value {
7         self.get()
8     }
9 }
10
11 struct Struct {
12     x: isize,
13 }
14
15 impl Get for Struct {
16     type Value = isize;
17     fn get(&self) -> &isize {
18         &self.x
19     }
20 }
21
22 fn main() {
23     let s = Struct {
24         x: 100,
25     };
26     assert_eq!(*s.grab(), 100);
27 }