v2 / vlib / v / tests / generics / generics_with_embed_generics_structs_test.v
29 lines · 23 sloc · 302 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1struct Foo[T] {
2 field T
3}
4
5struct Bar[T] {
6 Foo[T]
7}
8
9struct Baz[T] {
10 Bar[T]
11}
12
13struct OneLevelEmbed[T] {
14 Foo[T]
15}
16
17fn test_main() {
18 m := OneLevelEmbed[int]{}
19 assert m.field == 0
20}
21
22struct MultiLevelEmbed[T] {
23 Baz[T]
24}
25
26fn test_multi_level() {
27 m := MultiLevelEmbed[int]{}
28 assert m.field == 0
29}
30