mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
24 lines
272 B
V
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)
|
|
}
|