| 1 | struct List[T] { |
| 2 | pub mut: |
| 3 | head &ListNode[T] = unsafe { nil } |
| 4 | } |
| 5 | |
| 6 | struct ListNode[T] { |
| 7 | pub mut: |
| 8 | value T |
| 9 | next &ListNode[T] = unsafe { nil } |
| 10 | } |
| 11 | |
| 12 | fn list_new[T]() List[T] { |
| 13 | return List[T]{} |
| 14 | } |
| 15 | |
| 16 | fn listnode_new[T]() &ListNode[T] { |
| 17 | return &ListNode[T]{0, 0} |
| 18 | } |
| 19 | |
| 20 | fn (mut l List[T]) free() { |
| 21 | } |
| 22 | |
| 23 | fn test_generic_struct_free() { |
| 24 | mut list := list_new[string]() |
| 25 | println(list) |
| 26 | list.free() |
| 27 | assert true |
| 28 | } |
| 29 |