-
-
Save b10011/eb45c2e0a882019ee01d to your computer and use it in GitHub Desktop.
First Rust tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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