summaryrefslogtreecommitdiff
path: root/rust/rustlings/solutions/01_variables/variables4.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/rustlings/solutions/01_variables/variables4.rs')
-rw-r--r--rust/rustlings/solutions/01_variables/variables4.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/rust/rustlings/solutions/01_variables/variables4.rs b/rust/rustlings/solutions/01_variables/variables4.rs
new file mode 100644
index 0000000..7de6bcb
--- /dev/null
+++ b/rust/rustlings/solutions/01_variables/variables4.rs
@@ -0,0 +1,9 @@
+fn main() {
+ // In Rust, variables are immutable by default.
+ // Adding the `mut` keyword after `let` makes the declared variable mutable.
+ let mut x = 3;
+ println!("Number {x}");
+
+ x = 5;
+ println!("Number {x}");
+}