Values & References3 / 18
Up next

Copy types are duplicated

// i32 is Copy, so the caller keeps its own value
fn double(n: i32) -> i32 {
    n * 2
}

fn main() {
    let x = 5;
    let y = double(x);
    // x is still valid because it was copied, not moved
    println!("{x} {y}");
}
What you're solving

primitives copy instead of moving