From b8d413332890f54380076031e42214a6eb5e515f Mon Sep 17 00:00:00 2001 From: Christopher Girvin Date: Sat, 14 May 2022 16:21:32 -0400 Subject: [PATCH] variables done --- .gitignore | 1 + exercises/intro/intro1.rs | 1 - exercises/intro/intro2.rs | 3 +-- exercises/variables/variables1.rs | 3 +-- exercises/variables/variables2.rs | 3 +-- exercises/variables/variables3.rs | 3 +-- exercises/variables/variables4.rs | 2 +- exercises/variables/variables5.rs | 3 +-- exercises/variables/variables6.rs | 3 +-- 9 files changed, 8 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 253f8f33..f8897c3b 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ exercises/clippy/Cargo.lock .idea .vscode *.iml +rustlings/ diff --git a/exercises/intro/intro1.rs b/exercises/intro/intro1.rs index 1c4582de..4fde4bed 100644 --- a/exercises/intro/intro1.rs +++ b/exercises/intro/intro1.rs @@ -5,7 +5,6 @@ // ready for the next exercise, remove the `I AM NOT DONE` comment below. // Execute the command `rustlings hint intro1` for a hint. -// I AM NOT DONE fn main() { println!("Hello and"); diff --git a/exercises/intro/intro2.rs b/exercises/intro/intro2.rs index 97a073f0..7049068e 100644 --- a/exercises/intro/intro2.rs +++ b/exercises/intro/intro2.rs @@ -2,8 +2,7 @@ // Make the code print a greeting to the world. // Execute `rustlings hint intro2` for a hint. -// I AM NOT DONE fn main() { - println!("Hello {}!"); + println!("Hello {}!", word = String::from("world")); } diff --git a/exercises/variables/variables1.rs b/exercises/variables/variables1.rs index d1af8311..11443c9f 100644 --- a/exercises/variables/variables1.rs +++ b/exercises/variables/variables1.rs @@ -2,9 +2,8 @@ // Make me compile! // Execute the command `rustlings hint variables1` if you want a hint :) -// I AM NOT DONE fn main() { - x = 5; + let x: i32 = 5; println!("x has the value {}", x); } diff --git a/exercises/variables/variables2.rs b/exercises/variables/variables2.rs index 7774a8fb..0a5890c9 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 = 4; 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..bd09179d 100644 --- a/exercises/variables/variables4.rs +++ b/exercises/variables/variables4.rs @@ -1,9 +1,9 @@ // 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; + x = 10; println!("Number {}", x); } diff --git a/exercises/variables/variables5.rs b/exercises/variables/variables5.rs index 175eebb3..d61e6c1b 100644 --- a/exercises/variables/variables5.rs +++ b/exercises/variables/variables5.rs @@ -1,11 +1,10 @@ // 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); }