v2 / vlib / v / tests / options / option_embed_field_test.v
18 lines · 15 sloc · 279 bytes · ccb93e677c227e7a4616bcc322d91e2a32a2c7bb
Raw
1struct Foo {
2 optional_one ?string
3}
4
5struct Bar {
6 foo Foo
7}
8
9fn test_main() {
10 b := Bar{Foo{
11 optional_one: 'hello world'
12 }}
13 println(b.foo.optional_one)
14 x := b.foo.optional_one as string
15
16 assert x == 'hello world'
17 assert (b.foo.optional_one as string) == 'hello world'
18}
19