summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--variables/.gitignore18
-rw-r--r--variables/Cargo.toml9
-rw-r--r--variables/src/main.rs16
3 files changed, 43 insertions, 0 deletions
diff --git a/variables/.gitignore b/variables/.gitignore
new file mode 100644
index 0000000..e629269
--- /dev/null
+++ b/variables/.gitignore
@@ -0,0 +1,18 @@
+
+# Created by https://www.toptal.com/developers/gitignore/api/rust
+# Edit at https://www.toptal.com/developers/gitignore?templates=rust
+
+### Rust ###
+# Generated by Cargo
+# will have compiled files and executables
+/target/
+
+# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
+# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
+Cargo.lock
+
+# These are backup files generated by rustfmt
+**/*.rs.bk
+
+# End of https://www.toptal.com/developers/gitignore/api/rust
+
diff --git a/variables/Cargo.toml b/variables/Cargo.toml
new file mode 100644
index 0000000..cee94d1
--- /dev/null
+++ b/variables/Cargo.toml
@@ -0,0 +1,9 @@
+[package]
+name = "variables"
+version = "0.1.0"
+authors = ["jordan"]
+edition = "2018"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
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);
+}