-
Notifications
You must be signed in to change notification settings - Fork 1
/
impl.sharp
70 lines (56 loc) · 965 Bytes
/
impl.sharp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
use self::bingles::Test3;
//use self::bingles::printf;
fn malloc(i64 size) -> i8*;
fn free(i8* ptr);
fn printf(str format, ...) -> i32;
struct Test {
i32 a,
i32 b,
}
impl Test {
fn new(i32 a, i32 b) -> Test {
return Test {
a,
b,
};
}
fn set_a(self, i32 a) {
*self.a = a;
return;
}
}
struct Test2 {
Test3 a,
Test b,
}
impl Test2 {
fn set_a(self, Test3 a) {
*self.a.a = a;
return;
}
}
fn main() -> i32 {
let Test2 t = Test2 {
a: Test3 {
a: 0,
b: 0,
},
b: Test::new(9, 5),
};
printf("t.a.a: %d\n", t.a.a);
printf("t.b.a: %d\n", t.b.a);
t.set_a(Test3 {
a: 10,
b: 0,
});
t.b.set_a(25);
printf("t.a.a: %d\n", t.a.a);
printf("t.b.a: %d\n", t.b.a);
return 0;
}
mod bingles {
struct Test3 {
i32 a,
i32 b,
}
}