2

My simplified code:

fn f() -> (u32, u32) {
    (5, 5)
}

fn main() {
    let mut i = 6_u32;
    let mut j = 6_u32;

    // some condition
    if true {
        let (new_i, new_j) = f();
        i = new_i;
        j = new_j;
    }

    // code that use i and j
}

Is it possible to simplify the code:

let (new_i, new_j) = f();
i = new_i;
j = new_j;

In my real code, I pass 4 values in the tuple.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
user1244932
  • 7,352
  • 5
  • 46
  • 103

0 Answers0