| 1 | struct ABC { |
| 2 | mut: |
| 3 | s string |
| 4 | } |
| 5 | |
| 6 | fn test_shared_option() { |
| 7 | shared abc := foo() or { panic('scared') } |
| 8 | rlock abc { |
| 9 | println(abc) |
| 10 | assert abc.s == 'hello' |
| 11 | } |
| 12 | } |
| 13 | |
| 14 | fn foo() ?ABC { |
| 15 | mut a := ABC{} |
| 16 | a.bar()? |
| 17 | return a |
| 18 | } |
| 19 | |
| 20 | fn (mut a ABC) bar() ? { |
| 21 | a.s = 'hello' |
| 22 | println(a.s) |
| 23 | } |
| 24 |