Skip to content

Instantly share code, notes, and snippets.

@b10011
Created December 31, 2014 19:31
Show Gist options
  • Save b10011/eb45c2e0a882019ee01d to your computer and use it in GitHub Desktop.
Save b10011/eb45c2e0a882019ee01d to your computer and use it in GitHub Desktop.
First Rust tests
// Here it doesn't warn about x not being read.
fn main() {
let x = 5i;
let y = x;
println!("{}",y);
}
// 5
// Here it does warn. Why editing x after referencing it by y makes the difference that it throws warning?
fn main() {
let mut x = 5i;
let y = x;
x = 0;
println!("{}",y);
}
// warning: value assigned to `x` is never read, #[warn(unused_assignments)] on by default
// 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment