3 ms·
I think this part of the article has a typo (it is missing (2, 2) and a comma after the tuple in the vector macro assignment) Say I have a vector of pairs:
by MuffinFlavored 3y ago
I think this part of the article has a typo (it is missing (2, 2) and a comma after the tuple in the vector macro assignment)
Say I have a vector of pairs:
let the_data = vec![
(1, 2),
(2, 2)
(2, 3),
(5, 7),
(8, 8)];
I can grab an iterator out of it and do the same pattern matching in a for loop:
for (a, b) in the_data {
println!("({}, {})", a, b);
}
// prints
// (1, 2)
// (2, 3)
// (5, 7)
// (8, 8)