From 1a59f67d8720105279d2cf4146bd084c243a086e Mon Sep 17 00:00:00 2001 From: Paul Scarrone Date: Sun, 12 Feb 2023 19:26:09 -0500 Subject: [PATCH 1/7] variables 1 --- exercises/variables/variables1.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/exercises/variables/variables1.rs b/exercises/variables/variables1.rs index f4d182ac..84de9fdc 100644 --- a/exercises/variables/variables1.rs +++ b/exercises/variables/variables1.rs @@ -2,9 +2,7 @@ // Make me compile! // Execute `rustlings hint variables1` or use the `hint` watch subcommand for a hint. -// I AM NOT DONE - fn main() { - x = 5; + let x = 5; println!("x has the value {}", x); } From fa3c231e709d65c3ac72f77f927ecd0e8680b825 Mon Sep 17 00:00:00 2001 From: Paul Scarrone Date: Sun, 12 Feb 2023 19:27:22 -0500 Subject: [PATCH 2/7] variables 2 --- exercises/variables/variables2.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/exercises/variables/variables2.rs b/exercises/variables/variables2.rs index 641aeb8e..ea8b1076 100644 --- a/exercises/variables/variables2.rs +++ b/exercises/variables/variables2.rs @@ -1,10 +1,8 @@ // variables2.rs // Execute `rustlings hint variables2` or use the `hint` watch subcommand for a hint. -// I AM NOT DONE - fn main() { - let x; + let x = 10; if x == 10 { println!("x is ten!"); } else { From 44eb9f7c3c36e0d7a9179dbae514210c59d0c612 Mon Sep 17 00:00:00 2001 From: Paul Scarrone Date: Sun, 12 Feb 2023 19:28:54 -0500 Subject: [PATCH 3/7] variables 3 --- exercises/variables/variables3.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/variables/variables3.rs b/exercises/variables/variables3.rs index 819b1bc7..0f00c9f1 100644 --- a/exercises/variables/variables3.rs +++ b/exercises/variables/variables3.rs @@ -1,9 +1,9 @@ // variables3.rs // Execute `rustlings hint variables3` or use the `hint` watch subcommand for a hint. -// I AM NOT DONE - fn main() { let x: i32; + x = 10; println!("Number {}", x); + println!("Number {x}"); } From 62af9047c76abd742d32ef23219f62b7dfa09403 Mon Sep 17 00:00:00 2001 From: Paul Scarrone Date: Sun, 12 Feb 2023 19:29:56 -0500 Subject: [PATCH 4/7] variables 4 --- exercises/variables/variables4.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/exercises/variables/variables4.rs b/exercises/variables/variables4.rs index 54491b0a..8c2ddd6d 100644 --- a/exercises/variables/variables4.rs +++ b/exercises/variables/variables4.rs @@ -1,10 +1,8 @@ // variables4.rs // Execute `rustlings hint variables4` or use the `hint` watch subcommand for a hint. -// I AM NOT DONE - fn main() { - let x = 3; + let mut x = 3; println!("Number {}", x); x = 5; // don't change this line println!("Number {}", x); From 9bea3818b254561fc9d36413516f36c8ad2af4a8 Mon Sep 17 00:00:00 2001 From: Paul Scarrone Date: Sun, 12 Feb 2023 19:34:34 -0500 Subject: [PATCH 5/7] variables 5 --- exercises/variables/variables5.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/exercises/variables/variables5.rs b/exercises/variables/variables5.rs index 0e670d2a..65c0f3cc 100644 --- a/exercises/variables/variables5.rs +++ b/exercises/variables/variables5.rs @@ -1,11 +1,9 @@ // 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 + let number: u32 = 3; // don't rename this variable println!("Number plus two is : {}", number + 2); } From 09c4f660a5f9ec5df2a52c6ab65fe9068fc7547d Mon Sep 17 00:00:00 2001 From: Paul Scarrone Date: Sun, 12 Feb 2023 19:51:55 -0500 Subject: [PATCH 6/7] Some fun with scopes, shadowing and types in var 5 --- exercises/variables/variables5.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/exercises/variables/variables5.rs b/exercises/variables/variables5.rs index 65c0f3cc..7093a23c 100644 --- a/exercises/variables/variables5.rs +++ b/exercises/variables/variables5.rs @@ -6,4 +6,9 @@ fn main() { println!("Spell a Number : {}", number); let number: u32 = 3; // don't rename this variable println!("Number plus two is : {}", number + 2); + { + let number: f32 = 0.1; + println!("Number plus 1 is : {}", number + 1.0) + } + println!("Number plust 0.1 is : {}", number + 1.1 as u32) } From 11d2fee7a06c17f80241980e8c51158cd6bde9c4 Mon Sep 17 00:00:00 2001 From: Paul Scarrone Date: Sun, 12 Feb 2023 19:35:54 -0500 Subject: [PATCH 7/7] variables 6 --- exercises/variables/variables6.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/exercises/variables/variables6.rs b/exercises/variables/variables6.rs index a8520122..5021721f 100644 --- a/exercises/variables/variables6.rs +++ b/exercises/variables/variables6.rs @@ -1,9 +1,7 @@ // variables6.rs // Execute `rustlings hint variables6` or use the `hint` watch subcommand for a hint. -// I AM NOT DONE - -const NUMBER = 3; +const NUMBER: u32 = 3; fn main() { println!("Number {}", NUMBER); }