From d1a3ab5c54af5adb8d60b531a223f3dee8f2047e Mon Sep 17 00:00:00 2001 From: Rock070 Date: Sun, 17 Dec 2023 16:20:42 +0800 Subject: [PATCH] Refactor fill_vec function to create and fill the Vec internally --- exercises/06_move_semantics/move_semantics4.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/exercises/06_move_semantics/move_semantics4.rs b/exercises/06_move_semantics/move_semantics4.rs index 80b49dba..24d6e5cd 100644 --- a/exercises/06_move_semantics/move_semantics4.rs +++ b/exercises/06_move_semantics/move_semantics4.rs @@ -7,13 +7,11 @@ // Execute `rustlings hint move_semantics4` or use the `hint` watch subcommand // for a hint. -// I AM NOT DONE - #[test] fn main() { let vec0 = vec![22, 44, 66]; - let mut vec1 = fill_vec(vec0); + let vec1 = fill_vec(); assert_eq!(vec1, vec![22, 44, 66, 88]); } @@ -21,7 +19,7 @@ fn main() { // `fill_vec()` no longer takes `vec: Vec` as argument - don't change this! fn fill_vec() -> Vec { // Instead, let's create and fill the Vec in here - how do you do that? - let mut vec = vec; + let mut vec: Vec = vec![22, 44, 66]; vec.push(88);