rustZip usage example in Rust
Zip usage example in Rust:
let a = [1, 2, 3];
let b = [4, 5, 6];
let zipped = a.iter().zip(b.iter());
for (x, y) in zipped {
println!("x = {}, y = {}", x, y);
}
Output example
x = 1, y = 4
x = 2, y = 5
x = 3, y = 6
let a = [1, 2, 3];
creates an array of integerslet b = [4, 5, 6];
creates another array of integerslet zipped = a.iter().zip(b.iter());
creates a zipped iterator of the two arraysfor (x, y) in zipped {
iterates over the zipped iteratorprintln!("x = {}, y = {}", x, y);
prints the values of the two arrays
Helpful links
Related
More of Rust
- How to convert a Rust HashMap to a BTreeMap?
- How to use regex to match a group in Rust?
- How to use non-capturing groups in Rust regex?
- How to match a URL with a regex in Rust?
- How to use the global flag in a Rust regex?
- How to match digits with regex in Rust?
- How to use regex to match a double quote in Rust?
- How to create a HashSet from a Vec in Rust?
- How to print the keys of a Rust HashMap?
- How to implement PartialEq for a Rust HashMap?
See more codes...