Add code
This commit is contained in:
parent
e16855e607
commit
f95cd273d3
3 changed files with 13 additions and 0 deletions
1
2-map-in-rust/.gitignore
vendored
Normal file
1
2-map-in-rust/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/main
|
5
2-map-in-rust/Makefile
Normal file
5
2-map-in-rust/Makefile
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
all: main
|
||||||
|
./main
|
||||||
|
|
||||||
|
main: main.rs
|
||||||
|
rustc main.rs
|
7
2-map-in-rust/main.rs
Normal file
7
2-map-in-rust/main.rs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
fn main() {
|
||||||
|
let a: Vec<u32> = (0..10).collect();
|
||||||
|
let b: Vec<(u32, u32)> = a.iter().map(|&n| (n, n.pow(2))).collect();
|
||||||
|
for (n, nn) in b {
|
||||||
|
println!("{}: {}", n, nn);
|
||||||
|
}
|
||||||
|
}
|
Reference in a new issue