I have a min-heap of i32 in Rust, and I want to calculate the sum of its elements and store it in i32.
let mut total_sum = 0;
for current in min_heap {
total_sum = current + total_sum;
}
I am getting the following error when compiling:
cannot add `{integer}` to `Reverse<i32>`
You can simply call the
summethod on your iterator after mappingReverse<i32>'s inside your heap to their inner values.Some advices:
x = x + y, usex += yinstead;