v2 / vlib / v / tests / options / option_struct_init_with_opt_test.v
19 lines · 17 sloc · 197 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1struct Foo {
2 x ?string
3}
4
5fn test_main() {
6 x := ?string('hi')
7 foo := Foo{
8 x: x
9 }
10 assert foo.x? == 'hi'
11}
12
13fn test_none() {
14 x := ?string(none)
15 foo := Foo{
16 x: x
17 }
18 assert foo.x == none
19}
20