mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-04 01:39:18 +00:00
Refactor fill_vec function to create and fill the Vec internally
This commit is contained in:
parent
a898c058fc
commit
d1a3ab5c54
@ -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);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user