vxx2 / vlib / v / checker / tests / generic_mut_struct_index_err.vv
17 lines · 15 sloc · 216 bytes · 0c8ce3bcb9fd4a2e5bd5f991a5a07da976d780d7
Raw
1pub struct Heap[T] {
2mut:
3 arr []&T
4}
5
6fn (mut h Heap[T]) insert(mut element T, pos int) {
7 h[pos] = element
8}
9
10fn main() {
11 mut h := &Heap[int]{
12 arr: []&int{cap: 10}
13 }
14 mut a := 3
15 h.insert(mut &a, 0)
16 dump(h)
17}
18