Skip to content

Instantly share code, notes, and snippets.

@mitsuhiko
Forked from bstrie/bstrie
Last active December 14, 2015 06:18
Show Gist options
  • Save mitsuhiko/5041663 to your computer and use it in GitHub Desktop.
Save mitsuhiko/5041663 to your computer and use it in GitHub Desktop.
fn main() {
let numbers = [1, 2, 3];
let keys = ["foo", "bar", "baz"];
for iter::zip(numbers, keys) |&number, &key| {
io::println(fmt!("%s => %d", key, number));
}
for iter::enumerate(keys) |&index, &key| {
io::println(fmt!("%u => %s", index, key));
}
}
fn main() {
let numbers = [1, 2, 3];
let keys = ["foo", "bar", "baz"];
for (index, (&number, &key)): iter::enumerate(iter::zip(numbers, keys)) {
io::println(fmt!("%u: %s => %d", index, key, number));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment