Gitly
English
Русский
Español
日本語
中文
Português
Log in
Register
v2
/
vlib
/
v
/
tests
/
comptime
/
comptime_var_unwrap_test.v
26
lines
·
22
sloc
·
240 bytes
·
4eeae1cd939a17fe34ba75e1112113afe36eb741
Raw
1
struct
Foo {
2
a int
3
}
4
5
fn
Foo.init[T](a T) {
6
dump(a)
7
}
8
9
@[heap]
10
struct
Bar {
11
field int
12
}
13
14
fn
t[T](a ?T) T {
15
mut
b := a
16
if
b !=
none
{
17
Foo.init(b)
18
return
b
19
}
20
assert
false
21
return
T{}
22
}
23
24
fn
test_main() {
25
assert t(Bar{}) == Bar{}
26
}
27