1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/v/tests/shared_option_test.v
2023-01-09 09:36:45 +03:00

24 lines
272 B
V

struct ABC {
mut:
s string
}
fn test_shared_option() {
shared abc := foo() or { panic('scared') }
rlock abc {
println(abc)
assert abc.s == 'hello'
}
}
fn foo() ?ABC {
mut a := ABC{}
a.bar()?
return a
}
fn (mut a ABC) bar() ? {
a.s = 'hello'
println(a.s)
}