complete: vec
This commit is contained in:
parent
49a36bc041
commit
6680e6d202
|
@ -4,11 +4,9 @@
|
|||
// Make me compile and pass the test!
|
||||
// Execute the command `rustlings hint vec1` if you need hints.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
fn array_and_vec() -> ([i32; 4], Vec<i32>) {
|
||||
let a = [10, 20, 30, 40]; // a plain array
|
||||
let v = // TODO: declare your vector here with the macro for vectors
|
||||
let v: Vec<i32> = vec![10, 20, 30, 40];
|
||||
|
||||
(a, v)
|
||||
}
|
||||
|
|
|
@ -7,12 +7,9 @@
|
|||
// Execute the command `rustlings hint vec2` if you need
|
||||
// hints.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
fn vec_loop(mut v: Vec<i32>) -> Vec<i32> {
|
||||
for i in v.iter_mut() {
|
||||
// TODO: Fill this up so that each element in the Vec `v` is
|
||||
// multiplied by 2.
|
||||
*i*=2
|
||||
}
|
||||
|
||||
// At this point, `v` should be equal to [4, 8, 12, 16, 20].
|
||||
|
|
Loading…
Reference in a new issue