v2 / vlib / v / tests / options / option_ptr_arg_heap_test.v
25 lines · 21 sloc · 287 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1module main
2
3@[heap]
4struct Node[T] {
5mut:
6 value T
7 next ?&Node[T]
8}
9
10fn print_t1(node ?&Node[int]) {
11 println(node)
12}
13
14fn print_t2(mut node ?&Node[int]) {
15 n := node or { return }
16 println(n)
17}
18
19fn test_main() {
20 mut n := Node[int]{
21 value: 5
22 }
23 print_t1(n)
24 print_t2(mut n.next)
25}
26