可变与不可变

  • 不可变
  • 可变
  • 不可变借用
  • 可变借用
let x = 5;
x = 6;  // error
let mut x = 5;
x = 6
let mut x = 5;
let y = &mut x;
let mut x = 5;
let mut y = &mut x;
let (mut x,y) = (5,6)
fn foo(mut x:i32) {}

results matching ""

    No results matching ""