summaryrefslogtreecommitdiff
path: root/rustlings/solutions/01_variables
diff options
context:
space:
mode:
authorHunter Kvalevog <hunter@kvog.sh>2026-10-02 21:53:51 -0500
committerHunter Kvalevog <hunter@kvog.sh>2026-10-02 21:53:51 -0500
commit4dfc11d74ab02ac5765ae5d08fb750c91f4744b4 (patch)
tree17ba62056d6b691dd0217b0e8f1b3a5826dce0f6 /rustlings/solutions/01_variables
parent02d8f1c62896576e1266553a56980eddbc2a88d7 (diff)
rustlings: move to rust/
Diffstat (limited to 'rustlings/solutions/01_variables')
-rw-r--r--rustlings/solutions/01_variables/variables1.rs6
-rw-r--r--rustlings/solutions/01_variables/variables2.rs16
-rw-r--r--rustlings/solutions/01_variables/variables3.rs15
-rw-r--r--rustlings/solutions/01_variables/variables4.rs9
-rw-r--r--rustlings/solutions/01_variables/variables5.rs9
-rw-r--r--rustlings/solutions/01_variables/variables6.rs6
6 files changed, 0 insertions, 61 deletions
diff --git a/rustlings/solutions/01_variables/variables1.rs b/rustlings/solutions/01_variables/variables1.rs
deleted file mode 100644
index 58d046b..0000000
--- a/rustlings/solutions/01_variables/variables1.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-fn main() {
- // Declaring variables requires the `let` keyword.
- let x = 5;
-
- println!("x has the value {x}");
-}
diff --git a/rustlings/solutions/01_variables/variables2.rs b/rustlings/solutions/01_variables/variables2.rs
deleted file mode 100644
index 50b8d1b..0000000
--- a/rustlings/solutions/01_variables/variables2.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-fn main() {
- // The easiest way to fix the compiler error is to initialize the
- // variable `x`. By setting its value to an integer, Rust infers its type
- // as `i32` which is the default type for integers.
- let x = 42;
-
- // But we can enforce a type different from the default `i32` by adding
- // a type annotation:
- // let x: u8 = 42;
-
- if x == 10 {
- println!("x is ten!");
- } else {
- println!("x is not ten!");
- }
-}
diff --git a/rustlings/solutions/01_variables/variables3.rs b/rustlings/solutions/01_variables/variables3.rs
deleted file mode 100644
index 15f6557..0000000
--- a/rustlings/solutions/01_variables/variables3.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-#![allow(clippy::needless_late_init)]
-
-fn main() {
- // Reading uninitialized variables isn't allowed in Rust!
- // Therefore, we need to assign a value first.
- let x: i32 = 42;
-
- println!("Number {x}");
-
- // It is possible to declare a variable and initialize it later.
- // But it can't be used before initialization.
- let y: i32;
- y = 42;
- println!("Number {y}");
-}
diff --git a/rustlings/solutions/01_variables/variables4.rs b/rustlings/solutions/01_variables/variables4.rs
deleted file mode 100644
index 7de6bcb..0000000
--- a/rustlings/solutions/01_variables/variables4.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-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}");
-}
diff --git a/rustlings/solutions/01_variables/variables5.rs b/rustlings/solutions/01_variables/variables5.rs
deleted file mode 100644
index 0ea3903..0000000
--- a/rustlings/solutions/01_variables/variables5.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-fn main() {
- let number = "T-H-R-E-E";
- println!("Spell a number: {number}");
-
- // Using variable shadowing
- // https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html#shadowing
- let number = 3;
- println!("Number plus two is: {}", number + 2);
-}
diff --git a/rustlings/solutions/01_variables/variables6.rs b/rustlings/solutions/01_variables/variables6.rs
deleted file mode 100644
index 25b7a1e..0000000
--- a/rustlings/solutions/01_variables/variables6.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-// The type of constants must always be annotated.
-const NUMBER: u64 = 3;
-
-fn main() {
- println!("Number: {NUMBER}");
-}