From 3e427ac3a6eeabd26f267259c9f0a0502c1926d4 Mon Sep 17 00:00:00 2001 From: Artur Zinurov Date: Thu, 4 Jan 2024 23:07:56 -0600 Subject: [PATCH] primitive types done --- exercises/04_primitive_types/primitive_types1.rs | 5 ++--- exercises/04_primitive_types/primitive_types2.rs | 5 ++--- exercises/04_primitive_types/primitive_types3.rs | 5 +++-- exercises/04_primitive_types/primitive_types4.rs | 3 +-- exercises/04_primitive_types/primitive_types5.rs | 3 +-- exercises/04_primitive_types/primitive_types6.rs | 4 +--- 6 files changed, 10 insertions(+), 15 deletions(-) diff --git a/exercises/04_primitive_types/primitive_types1.rs b/exercises/04_primitive_types/primitive_types1.rs index 36633400..22461190 100644 --- a/exercises/04_primitive_types/primitive_types1.rs +++ b/exercises/04_primitive_types/primitive_types1.rs @@ -3,17 +3,16 @@ // Fill in the rest of the line that has code missing! No hints, there's no // tricks, just get used to typing these :) -// I AM NOT DONE fn main() { // Booleans (`bool`) - let is_morning = true; + let is_morning: bool = true; if is_morning { println!("Good morning!"); } - let // Finish the rest of this line like the example! Or make it be false! + let is_evening: bool = true; if is_evening { println!("Good evening!"); } diff --git a/exercises/04_primitive_types/primitive_types2.rs b/exercises/04_primitive_types/primitive_types2.rs index f1616ed3..c7184ae5 100644 --- a/exercises/04_primitive_types/primitive_types2.rs +++ b/exercises/04_primitive_types/primitive_types2.rs @@ -3,14 +3,13 @@ // Fill in the rest of the line that has code missing! No hints, there's no // tricks, just get used to typing these :) -// I AM NOT DONE fn main() { // Characters (`char`) // Note the _single_ quotes, these are different from the double quotes // you've been seeing around. - let my_first_initial = 'C'; + let my_first_initial: char = 'C'; if my_first_initial.is_alphabetic() { println!("Alphabetical!"); } else if my_first_initial.is_numeric() { @@ -19,7 +18,7 @@ fn main() { println!("Neither alphabetic nor numeric!"); } - let // Finish this line like the example! What's your favorite character? + let your_character: char = '#'; // Try a letter, try a number, try a special character, try a character // from a different language than your own, try an emoji! if your_character.is_alphabetic() { diff --git a/exercises/04_primitive_types/primitive_types3.rs b/exercises/04_primitive_types/primitive_types3.rs index 8b0de44e..464385dc 100644 --- a/exercises/04_primitive_types/primitive_types3.rs +++ b/exercises/04_primitive_types/primitive_types3.rs @@ -5,10 +5,10 @@ // Execute `rustlings hint primitive_types3` or use the `hint` watch subcommand // for a hint. -// I AM NOT DONE + fn main() { - let a = ??? + let a = ["s t u f f "; 100]; if a.len() >= 100 { println!("Wow, that's a big array!"); @@ -16,4 +16,5 @@ fn main() { println!("Meh, I eat arrays like that for breakfast."); panic!("Array not big enough, more elements needed") } + //print!("{:#?}",a) } diff --git a/exercises/04_primitive_types/primitive_types4.rs b/exercises/04_primitive_types/primitive_types4.rs index d44d8776..9564c7a9 100644 --- a/exercises/04_primitive_types/primitive_types4.rs +++ b/exercises/04_primitive_types/primitive_types4.rs @@ -5,13 +5,12 @@ // Execute `rustlings hint primitive_types4` or use the `hint` watch subcommand // for a hint. -// I AM NOT DONE #[test] fn slice_out_of_array() { let a = [1, 2, 3, 4, 5]; - let nice_slice = ??? + let nice_slice = &a[1..4]; assert_eq!([2, 3, 4], nice_slice) } diff --git a/exercises/04_primitive_types/primitive_types5.rs b/exercises/04_primitive_types/primitive_types5.rs index f646986e..887a6c91 100644 --- a/exercises/04_primitive_types/primitive_types5.rs +++ b/exercises/04_primitive_types/primitive_types5.rs @@ -5,11 +5,10 @@ // Execute `rustlings hint primitive_types5` or use the `hint` watch subcommand // for a hint. -// I AM NOT DONE fn main() { let cat = ("Furry McFurson", 3.5); - let /* your pattern here */ = cat; + let ( name, age ) = cat; println!("{} is {} years old.", name, age); } diff --git a/exercises/04_primitive_types/primitive_types6.rs b/exercises/04_primitive_types/primitive_types6.rs index 07cc46c6..0ed7cfd2 100644 --- a/exercises/04_primitive_types/primitive_types6.rs +++ b/exercises/04_primitive_types/primitive_types6.rs @@ -6,13 +6,11 @@ // Execute `rustlings hint primitive_types6` or use the `hint` watch subcommand // for a hint. -// I AM NOT DONE - #[test] fn indexing_tuple() { let numbers = (1, 2, 3); // Replace below ??? with the tuple indexing syntax. - let second = ???; + let second = numbers.1; assert_eq!(2, second, "This is not the 2nd number in the tuple!")