blog podcast

Friend With Rust

I had a vector from which I wanted to sum three values together. I had another vector with the indexes of those three values. Now normally I would just have expected Rust to prevent me from doing whatever I wanted to do, something like this.

But behold my surprise, it worked. Hmm, seems like Rust can be kind when it wants to.

Code of the Day

indexes.iter().map(|i| &sorted[*i]).sum::<i32>();