| 1 | pub struct Node[T] { |
| 2 | value T |
| 3 | points_to []&Node[T] |
| 4 | } |
| 5 | |
| 6 | fn test_generics_with_recursive_generics_struct() { |
| 7 | mid := &Node[string]{ |
| 8 | value: 'Middle' |
| 9 | } |
| 10 | finish := &Node[string]{ |
| 11 | value: 'Finish' |
| 12 | } |
| 13 | |
| 14 | graph := &Node[string]{ |
| 15 | value: 'Start' |
| 16 | points_to: [ |
| 17 | &Node[string]{ |
| 18 | value: 'TopLeft' |
| 19 | points_to: [ |
| 20 | finish, |
| 21 | mid, |
| 22 | ] |
| 23 | }, |
| 24 | ] |
| 25 | } |
| 26 | |
| 27 | println(graph.points_to[0].value) |
| 28 | assert graph.points_to[0].value == 'TopLeft' |
| 29 | } |
| 30 |