summaryrefslogtreecommitdiff
path: root/exercises/01_variables
diff options
context:
space:
mode:
Diffstat (limited to 'exercises/01_variables')
-rw-r--r--exercises/01_variables/variables1.rs13
-rw-r--r--exercises/01_variables/variables2.rs9
-rw-r--r--exercises/01_variables/variables3.rs11
-rw-r--r--exercises/01_variables/variables4.rs15
-rw-r--r--exercises/01_variables/variables5.rs17
-rw-r--r--exercises/01_variables/variables6.rs11
6 files changed, 22 insertions, 54 deletions
diff --git a/exercises/01_variables/variables1.rs b/exercises/01_variables/variables1.rs
index b3e089a..0a9e554 100644
--- a/exercises/01_variables/variables1.rs
+++ b/exercises/01_variables/variables1.rs
@@ -1,13 +1,6 @@
-// variables1.rs
-//
-// Make me compile!
-//
-// Execute `rustlings hint variables1` or use the `hint` watch subcommand for a
-// hint.
-
-// I AM NOT DONE
-
fn main() {
+ // TODO: Add missing keyword.
x = 5;
- println!("x has the value {}", x);
+
+ println!("x has the value {x}");
}
diff --git a/exercises/01_variables/variables2.rs b/exercises/01_variables/variables2.rs
index e1c23ed..e2a3603 100644
--- a/exercises/01_variables/variables2.rs
+++ b/exercises/01_variables/variables2.rs
@@ -1,12 +1,7 @@
-// variables2.rs
-//
-// Execute `rustlings hint variables2` or use the `hint` watch subcommand for a
-// hint.
-
-// I AM NOT DONE
-
fn main() {
+ // TODO: Change the line below to fix the compiler error.
let x;
+
if x == 10 {
println!("x is ten!");
} else {
diff --git a/exercises/01_variables/variables3.rs b/exercises/01_variables/variables3.rs
index 86bed41..06f35bb 100644
--- a/exercises/01_variables/variables3.rs
+++ b/exercises/01_variables/variables3.rs
@@ -1,11 +1,6 @@
-// variables3.rs
-//
-// Execute `rustlings hint variables3` or use the `hint` watch subcommand for a
-// hint.
-
-// I AM NOT DONE
-
fn main() {
+ // TODO: Change the line below to fix the compiler error.
let x: i32;
- println!("Number {}", x);
+
+ println!("Number {x}");
}
diff --git a/exercises/01_variables/variables4.rs b/exercises/01_variables/variables4.rs
index 5394f39..6c138b1 100644
--- a/exercises/01_variables/variables4.rs
+++ b/exercises/01_variables/variables4.rs
@@ -1,13 +1,8 @@
-// variables4.rs
-//
-// Execute `rustlings hint variables4` or use the `hint` watch subcommand for a
-// hint.
-
-// I AM NOT DONE
-
+// TODO: Fix the compiler error.
fn main() {
let x = 3;
- println!("Number {}", x);
- x = 5; // don't change this line
- println!("Number {}", x);
+ println!("Number {x}");
+
+ x = 5; // Don't change this line
+ println!("Number {x}");
}
diff --git a/exercises/01_variables/variables5.rs b/exercises/01_variables/variables5.rs
index a29b38b..49db8e9 100644
--- a/exercises/01_variables/variables5.rs
+++ b/exercises/01_variables/variables5.rs
@@ -1,13 +1,8 @@
-// variables5.rs
-//
-// Execute `rustlings hint variables5` or use the `hint` watch subcommand for a
-// hint.
-
-// I AM NOT DONE
-
fn main() {
- let number = "T-H-R-E-E"; // don't change this line
- println!("Spell a Number : {}", number);
- number = 3; // don't rename this variable
- println!("Number plus two is : {}", number + 2);
+ let number = "T-H-R-E-E"; // Don't change this line
+ println!("Spell a number: {}", number);
+
+ // TODO: Fix the compiler error by changing the line below without renaming the variable.
+ number = 3;
+ println!("Number plus two is: {}", number + 2);
}
diff --git a/exercises/01_variables/variables6.rs b/exercises/01_variables/variables6.rs
index 853183b..4a040fd 100644
--- a/exercises/01_variables/variables6.rs
+++ b/exercises/01_variables/variables6.rs
@@ -1,11 +1,6 @@
-// variables6.rs
-//
-// Execute `rustlings hint variables6` or use the `hint` watch subcommand for a
-// hint.
-
-// I AM NOT DONE
-
+// TODO: Change the line below to fix the compiler error.
const NUMBER = 3;
+
fn main() {
- println!("Number {}", NUMBER);
+ println!("Number: {NUMBER}");
}