News for hackers. Stuff that matters.
Re:Rust for C++ Programmers – Part 9 by kwantam on Thursday July 17, 2014 @07:18PM (#8050795)
You can destructure without moving, as you suggest, by taking a reference.

Move:

    let x = (box 2u, box 4u);
    let (y, z) = match x {
        (first, second) => (first, second)
    };
    println!("x is {}", x);
    // this will not compile: x is moved into y and z
Reference:

    let x = (box 2u, box 4u);
    let (y, z) = match x {
        (ref first, ref second) => (first, second)
    };
    println!("x is {}", x);
    // this works fine
Re:Rust for C++ Programmers – Part 9 by dbaupp on Thursday July 17, 2014 @07:27PM (#8050833)
(The `match` is unnecessary in both examples: the patterns are irrefutable and so work directly in `let`.)