]> git.proxmox.com Git - rustc.git/blame - src/test/ui/associated-types/associated-types-in-fn.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / ui / associated-types / associated-types-in-fn.rs
CommitLineData
b7449926 1// run-pass
c34b1796 2
1a4d82fc
JJ
3trait Get {
4 type Value;
5 fn get(&self) -> &<Self as Get>::Value;
6}
223e47cc 7
1a4d82fc 8struct Struct {
c34b1796 9 x: isize,
1a4d82fc 10}
223e47cc 11
1a4d82fc 12impl Get for Struct {
c34b1796
AL
13 type Value = isize;
14 fn get(&self) -> &isize {
1a4d82fc
JJ
15 &self.x
16 }
17}
18
19fn grab<T:Get>(x: &T) -> &<T as Get>::Value {
20 x.get()
21}
223e47cc
LB
22
23fn main() {
1a4d82fc
JJ
24 let s = Struct {
25 x: 100,
223e47cc 26 };
1a4d82fc 27 assert_eq!(*grab(&s), 100);
223e47cc 28}