Values & References12 / 18
Up next

Make a struct Copy

// deriving Copy makes a small struct behave like a primitive
#[derive(Clone, Copy, Debug)]
struct Point {
    x: i32,
    y: i32,
}

fn show(p: Point) {
    println!("{:?}", p);
}

fn main() {
    let p = Point { x: 1, y: 2 };
    show(p);
    // p is still usable because Point is Copy
    show(p);
}
What you're solving

derive Copy so it passes by value