From 8ceb6239563aac2e3a9c167dc03bb8bdf60493b6 Mon Sep 17 00:00:00 2001 From: Leonardo Freua Date: Tue, 14 Sep 2021 10:16:48 -0300 Subject: [PATCH] Solve variable exercises. --- exercises/variables/variables1.rs | 3 +-- exercises/variables/variables2.rs | 3 +-- exercises/variables/variables3.rs | 3 +-- exercises/variables/variables4.rs | 4 +--- exercises/variables/variables5.rs | 4 +--- exercises/variables/variables6.rs | 3 +-- 6 files changed, 6 insertions(+), 14 deletions(-) diff --git a/exercises/variables/variables1.rs b/exercises/variables/variables1.rs index 4a3af73c..149d5ce8 100644 --- a/exercises/variables/variables1.rs +++ b/exercises/variables/variables1.rs @@ -6,9 +6,8 @@ // even after you already figured it out. If you got everything working and // feel ready for the next exercise, remove the `I AM NOT DONE` comment below. -// I AM NOT DONE fn main() { - x = 5; + let x = 5; println!("x has the value {}", x); } diff --git a/exercises/variables/variables2.rs b/exercises/variables/variables2.rs index 7774a8fb..9221896f 100644 --- a/exercises/variables/variables2.rs +++ b/exercises/variables/variables2.rs @@ -1,10 +1,9 @@ // variables2.rs // Make me compile! Execute the command `rustlings hint variables2` if you want a hint :) -// I AM NOT DONE fn main() { - let x; + let x: i32 = 5; if x == 10 { println!("Ten!"); } else { diff --git a/exercises/variables/variables3.rs b/exercises/variables/variables3.rs index 30ec48ff..3566ef22 100644 --- a/exercises/variables/variables3.rs +++ b/exercises/variables/variables3.rs @@ -1,10 +1,9 @@ // variables3.rs // Make me compile! Execute the command `rustlings hint variables3` if you want 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); diff --git a/exercises/variables/variables4.rs b/exercises/variables/variables4.rs index 77f1e9ab..ee043ef0 100644 --- a/exercises/variables/variables4.rs +++ b/exercises/variables/variables4.rs @@ -1,9 +1,7 @@ // variables4.rs // Make me compile! Execute the command `rustlings hint variables4` if you want a hint :) -// I AM NOT DONE - fn main() { - let x: i32; + let x: i32 = 4; println!("Number {}", x); } diff --git a/exercises/variables/variables5.rs b/exercises/variables/variables5.rs index 175eebb3..e31ab3f2 100644 --- a/exercises/variables/variables5.rs +++ b/exercises/variables/variables5.rs @@ -1,11 +1,9 @@ // variables5.rs // Make me compile! Execute the command `rustlings hint variables5` if you want 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; + let number = 3; println!("Number plus two is : {}", number + 2); } diff --git a/exercises/variables/variables6.rs b/exercises/variables/variables6.rs index 98666914..ebd911d3 100644 --- a/exercises/variables/variables6.rs +++ b/exercises/variables/variables6.rs @@ -1,9 +1,8 @@ // variables6.rs // Make me compile! Execute the command `rustlings hint variables6` if you want a hint :) -// I AM NOT DONE -const NUMBER = 3; +const NUMBER: i32 = 3; fn main() { println!("Number {}", NUMBER); }