Refactor fill_vec function to create and fill the Vec internally

This commit is contained in:
Rock070 2023-12-17 16:20:42 +08:00
parent a898c058fc
commit d1a3ab5c54

View File

@ -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<i32>` as argument - don't change this!
fn fill_vec() -> Vec<i32> {
// Instead, let's create and fill the Vec in here - how do you do that?
let mut vec = vec;
let mut vec: Vec<i32> = vec![22, 44, 66];
vec.push(88);