summaryrefslogtreecommitdiff
path: root/exercises
diff options
context:
space:
mode:
Diffstat (limited to 'exercises')
-rw-r--r--exercises/primitive_types/README.md1
-rw-r--r--exercises/primitive_types/primitive_types4.rs29
2 files changed, 25 insertions, 5 deletions
diff --git a/exercises/primitive_types/README.md b/exercises/primitive_types/README.md
index b53394a..daa70ee 100644
--- a/exercises/primitive_types/README.md
+++ b/exercises/primitive_types/README.md
@@ -6,3 +6,4 @@ compiler. In this section, we'll go through the most important ones.
#### Book Sections
- [Data Types](https://doc.rust-lang.org/stable/book/ch03-02-data-types.html)
+- [The Slice Type](https://doc.rust-lang.org/stable/book/ch04-03-slices.html)
diff --git a/exercises/primitive_types/primitive_types4.rs b/exercises/primitive_types/primitive_types4.rs
index 1147cf7..e1ccdbc 100644
--- a/exercises/primitive_types/primitive_types4.rs
+++ b/exercises/primitive_types/primitive_types4.rs
@@ -2,16 +2,13 @@
// Get a slice out of Array a where the ??? is so that the `if` statement
// returns true. Scroll down for hints!!
+#[test]
fn main() {
let a = [1, 2, 3, 4, 5];
let nice_slice = ???
- if nice_slice == [2, 3, 4] {
- println!("Nice slice!");
- } else {
- println!("Not quite what I was expecting... I see: {:?}", nice_slice);
- }
+ assert_eq!([2, 3, 4], nice_slice)
}
@@ -38,6 +35,28 @@ fn main() {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// Take a look at the Understanding Ownership -> Slices -> Other Slices section of the book:
// https://doc.rust-lang.org/book/ch04-03-slices.html
// and use the starting and ending indices of the items in the Array