v2 / vlib / v / fmt / tests / struct_init_with_ref_cast_keep.vv
22 lines · 19 sloc · 208 bytes · bb9d268bd913107625347ab047da7b1756859736
Raw
1struct Foo {
2 f int = 123
3}
4
5struct Bar {
6 f &Foo = &Foo(0)
7}
8
9struct Zar {
10 f Foo
11}
12
13fn main() {
14 b := &Bar{
15 f: &Foo(32)
16 }
17 c := &Zar{
18 f: Foo{456}
19 }
20 assert ptr_str(b.f) == '20'
21 assert c.f.f == 456
22}
23