| 1 | fn separate_wires(coo_adj_wires [][2]u32, id u64) [][2]u32 { |
| 2 | return [][2]u32{len: coo_adj_wires.len, init: coo_adj_wires[index]} |
| 3 | } |
| 4 | |
| 5 | fn fixed_array_len(mut arr []int) int { |
| 6 | return arr.len |
| 7 | } |
| 8 | |
| 9 | fn fixed_array_generic_len[T](mut arr []T) int { |
| 10 | return arr.len |
| 11 | } |
| 12 | |
| 13 | fn fixed_array_generic_dispatch[T](mut val T) int { |
| 14 | $if T is $array_fixed { |
| 15 | return fixed_array_generic_len(mut val) |
| 16 | } |
| 17 | return -1 |
| 18 | } |
| 19 | |
| 20 | fn test_main() { |
| 21 | t := separate_wires([[u32(1), 2]!], 0) |
| 22 | assert t.str() == '[[1, 2]]' |
| 23 | } |
| 24 | |
| 25 | fn test_fixed_array_can_be_passed_to_array_param() { |
| 26 | mut fixed := [3]int{} |
| 27 | assert fixed_array_len(mut fixed) == 3 |
| 28 | } |
| 29 | |
| 30 | fn test_fixed_array_can_be_passed_to_generic_array_param() { |
| 31 | mut fixed := [3]int{} |
| 32 | assert fixed_array_generic_dispatch(mut fixed) == 3 |
| 33 | } |
| 34 | |