Learning Rust, one of the coolest things I've noticed is how often it is intuitive to use destructuring. I'm currently working on a problem that involves iteration over two lists and comparing elements that have the same index. I find myself wishing I had some kind of syntax similar to
for (possible_item, possible_other_item) in (list1.iter(), list_two.iter())
{
// Do stuff with the items.
// possible_item and possible_other_item would be Option types
// In case list1 and list2 had different lengths
}
Does anyone know of something similar to this in any programming language? In rust you can destructure HashMaps as (key, value) tuples, so I feel like this syntax is possible to implement.