From 087226959cdf861ae4f6eb6eb68cfae9f7eb0fd4 Mon Sep 17 00:00:00 2001 From: Chris Girvin Date: Mon, 16 May 2022 17:47:59 -0400 Subject: [PATCH] update break --- exercises/primitive_types/primitive_types1.rs | 6 ++---- exercises/primitive_types/primitive_types2.rs | 10 ++++------ exercises/primitive_types/primitive_types3.rs | 4 +--- exercises/primitive_types/primitive_types4.rs | 16 ++++++++++++++-- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/exercises/primitive_types/primitive_types1.rs b/exercises/primitive_types/primitive_types1.rs index 09121392..49b523fd 100644 --- a/exercises/primitive_types/primitive_types1.rs +++ b/exercises/primitive_types/primitive_types1.rs @@ -2,17 +2,15 @@ // 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; // Finish the rest of this line like the example! Or make it be false! if is_evening { println!("Good evening!"); } diff --git a/exercises/primitive_types/primitive_types2.rs b/exercises/primitive_types/primitive_types2.rs index 6576a4d5..4a8459c6 100644 --- a/exercises/primitive_types/primitive_types2.rs +++ b/exercises/primitive_types/primitive_types2.rs @@ -2,12 +2,10 @@ // 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`) - 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() { @@ -16,9 +14,9 @@ fn main() { println!("Neither alphabetic nor numeric!"); } - let // Finish this line like the example! What's your favorite character? - // Try a letter, try a number, try a special character, try a character - // from a different language than your own, try an emoji! + let your_character: char = '1'; // Finish this line like the example! What's your favorite character? + // 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() { println!("Alphabetical!"); } else if your_character.is_numeric() { diff --git a/exercises/primitive_types/primitive_types3.rs b/exercises/primitive_types/primitive_types3.rs index aaa518be..dd667b33 100644 --- a/exercises/primitive_types/primitive_types3.rs +++ b/exercises/primitive_types/primitive_types3.rs @@ -2,10 +2,8 @@ // Create an array with at least 100 elements in it where the ??? is. // Execute `rustlings hint primitive_types3` for hints! -// I AM NOT DONE - fn main() { - let a = ??? + let a = [0; 100]; if a.len() >= 100 { println!("Wow, that's a big array!"); diff --git a/exercises/primitive_types/primitive_types4.rs b/exercises/primitive_types/primitive_types4.rs index 10b553e9..42092e36 100644 --- a/exercises/primitive_types/primitive_types4.rs +++ b/exercises/primitive_types/primitive_types4.rs @@ -2,13 +2,25 @@ // Get a slice out of Array a where the ??? is so that the test passes. // Execute `rustlings hint primitive_types4` for hints!! -// I AM NOT DONE +// // original code +// #[test] +// fn slice_out_of_array() { +// let a = [1, 2, 3, 4, 5]; +// let nice_slice = ??? + +// assert_eq!([2, 3, 4], nice_slice) +// } +// // end of original code + +// solution #[test] fn slice_out_of_array() { let a = [1, 2, 3, 4, 5]; - let nice_slice = ??? + // create slice from borrowed array `a` + let nice_slice = &a[1..4]; assert_eq!([2, 3, 4], nice_slice) } +// end of solution