trpl-zh-cn/listings/ch13-functional-features/listing-13-15/src/main.rs

10 lines
190 B
Rust

fn main() {
// ANCHOR: here
let v1: Vec<i32> = vec![1, 2, 3];
let v2: Vec<_> = v1.iter().map(|x| x + 1).collect();
assert_eq!(v2, vec![2, 3, 4]);
// ANCHOR_END: here
}