Skip to content

Instantly share code, notes, and snippets.

@wurmr
Created March 15, 2018 20:00
Show Gist options
  • Save wurmr/19dd79b513e36d70946b6ad743233700 to your computer and use it in GitHub Desktop.
Save wurmr/19dd79b513e36d70946b6ad743233700 to your computer and use it in GitHub Desktop.
Rust variable shadowing, why?
fn main() {
let foo = 3;
println!("{}", foo);
let foo = "hi";
println!("{}", foo);
let mut foo = 2.3;
println!("{}", foo);
foo = "this string will break, foo is a floating-point"
println!("{}", foo);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment