v2 / vlib / v / tests / options / option_ptr_nil_test.v
21 lines · 18 sloc · 187 bytes · ef9bb8e628f3421447920d871b5f01c34af00f6b
Raw
1struct Foo {
2 name ?&string
3}
4
5struct Foo2 {
6mut:
7 name ?&string
8}
9
10fn test_1() {
11 _ := Foo{
12 name: unsafe { nil }
13 }
14}
15
16fn test_2() {
17 mut foo := Foo2{}
18 unsafe {
19 foo.name = nil
20 }
21}
22