v2 / vlib / v / debug / tests / interface_var.vv
39 lines · 33 sloc · 386 bytes · f0d53008c5f4281797f86ab2b4e0f30610b5379a
Raw
1interface ITest {
2 a MySum
3}
4
5struct Test {
6 a MySum
7}
8
9type MySum = bool | int
10
11fn interface_var(a ITest) {
12 match a {
13 Test {
14 $dbg;
15 }
16 else {}
17 }
18}
19
20struct MyTest {
21 t ITest
22}
23
24fn struct_to_interface_field() {
25 t1 := Test{}
26 _ := MyTest{
27 t: t1
28 }
29 mut t2 := Test{}
30 _ := MyTest{
31 t: t2
32 }
33 $dbg;
34}
35
36fn main() {
37 interface_var(Test{ a: true })
38 struct_to_interface_field()
39}
40