Destructuring

  • Destructuring is done primarily through the let and match statements

  • A let pulls the variables out into the current scope, whereas match introduces a new scope

fn foo(pair: (int, int)) {
    let (x, y) = pair;
    // we can now use x and y anywhere in foo

    match pair {
        (x, y) => {
            // x and y can only be used in this scope
        }
    }
}