v2 / vlib / v / tests / options / option_generic_alias_test.v
17 lines · 15 sloc · 217 bytes · 81b4a64f184e9c1579d0d5b1d9164615682339b9
Raw
1type I64 = i64
2
3fn test[T](a ?T) ?T {
4 w := ?T(a)
5 return w
6}
7
8fn test_main() {
9 a := ?i64(123)
10 b := test[I64](a)
11 println(b)
12 assert b != none
13 assert b? == 123
14 c := test[I64](none)
15 println(c)
16 assert c == none
17}
18