From 6e4f0b4c6d7f7ad0eaaae5f4f2e2f3a08881ee35 Mon Sep 17 00:00:00 2001 From: Jordan Gong Date: Tue, 4 Aug 2020 18:41:09 +0800 Subject: Play around with variables --- variables/src/main.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 variables/src/main.rs (limited to 'variables/src/main.rs') diff --git a/variables/src/main.rs b/variables/src/main.rs new file mode 100644 index 0000000..3a4394a --- /dev/null +++ b/variables/src/main.rs @@ -0,0 +1,16 @@ +fn main() { + /* mutability */ + let mut x = 5; + println!("The variable of x is: {}", x); + x = 6; + println!("The variable of x is: {}", x); + + /* shadowing */ + let x = 5; + + let x = x + 1; + + let x = x * 2; + + println!("The value of x is: {}", x); +} -- cgit v1.2.3