From 66e91a799ed8dfbddbbf68ac9e3a89503f43c004 Mon Sep 17 00:00:00 2001 From: bahamoth Date: Fri, 2 Sep 2022 21:24:29 +0900 Subject: [PATCH] exercise done: primitive_types5 --- exercises/primitive_types/primitive_types4.rs | 3 +-- exercises/primitive_types/primitive_types5.rs | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/exercises/primitive_types/primitive_types4.rs b/exercises/primitive_types/primitive_types4.rs index 71fa243cfb..0b6d85f5ee 100644 --- a/exercises/primitive_types/primitive_types4.rs +++ b/exercises/primitive_types/primitive_types4.rs @@ -2,13 +2,12 @@ // Get a slice out of Array a where the ??? is so that the test passes. // 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/primitive_types/primitive_types5.rs b/exercises/primitive_types/primitive_types5.rs index 4fd9141fe6..7e706478c8 100644 --- a/exercises/primitive_types/primitive_types5.rs +++ b/exercises/primitive_types/primitive_types5.rs @@ -2,11 +2,10 @@ // Destructure the `cat` tuple so that the println will work. // 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: &str = cat.0; + let age: f64 = cat.1; println!("{} is {} years old.", name, age); }