Hello everybody,
I am fairly new to Rust - in fact started a few days ago. What I try to achieve is the following:
There is a sorted vector of tuples - for simplicity let's say that the tuple is comprised of 2 integers. E.g:
let mut v = vec![(1, 1), (1, 1), (1, 3), (1, 4), (2, 2), (2, 4), (2, 6)];
Now my questions is how to end up with a vector (could be the same one) that contains also tuples but with unique first element and the second element in the tuple is the sum of all the second tuple elements of the first vector corresponding to the unique first element, i.e. I want to end up with:
[(1, 9), (2, 12)]
Thanks for taking the time to read my question.