Skip to content

Instantly share code, notes, and snippets.

@jorendorff
Created November 25, 2015 11:41
Show Gist options
  • Select an option

  • Save jorendorff/a9f4421f2e210776f345 to your computer and use it in GitHub Desktop.

Select an option

Save jorendorff/a9f4421f2e210776f345 to your computer and use it in GitHub Desktop.
// variables are immutable by default
fn main() {
let x = 1;
x = 2; // error: re-assignment of immutable variable `x`
let nums = vec![1, 2, 3];
nums.push(4); // error: cannot borrow immutable local variable `nums` as mutable
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment