v2 / vlib / v / tests / generics / generic_struct_field_unwrap_test.v
23 lines · 19 sloc · 286 bytes · aa7de61e44c0e65f7824c8d9793a91fc6d228960
Raw
1struct Test[T] {
2pub:
3 value T
4}
5
6struct AuxTest[T] {
7pub:
8 any_value Test[T]
9}
10
11fn decode[T](arg Test[T]) !Test[T] {
12 return Test[T]{}
13}
14
15pub fn initializing[T]() !AuxTest[T] {
16 return AuxTest[T]{
17 any_value: decode[T](Test[T]{})!
18 }
19}
20
21fn test_main() {
22 dump(initializing[int]()!)
23}
24