How can I reduce an Iterator
of booleans using the &&
operator? Here is an example (just the relevant part):
let row: Vec<(u32, bool)> = vec![(12, true), (13, false), (15, true)];
row.iter()
.map(|it| {
let (_, marked) = it;
marked
})
.reduce(|acc, mk | acc && mk);
The compiler recommends dereferencing acc
first, then dereferencing mk
, and finally borrowing the whole expression. It's a quite simple operation but I'm unable to find the Rustacean way to do it.