面试题答案
一键面试struct Point {
x: i32,
y: i32,
}
fn main() {
let points = vec![
Point { x: 1, y: 2 },
Point { x: 3, y: 4 },
Point { x: 5, y: 6 },
];
let doubled_points: Vec<Point> = points.into_iter()
.map(|point| Point {
x: point.x * 2,
y: point.y * 2,
})
.collect();
println!("{:?}", doubled_points);
}