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