diff --git a/exercises/collections/vec1.rs b/exercises/collections/vec1.rs index b144fb94..ddd39644 100644 --- a/exercises/collections/vec1.rs +++ b/exercises/collections/vec1.rs @@ -4,11 +4,10 @@ // 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) { let a = [10, 20, 30, 40]; // a plain array - let v = // TODO: declare your vector here with the macro for vectors + let v = vec![10,20,30,40];// TODO: declare your vector here with the macro for vectors (a, v) } diff --git a/exercises/collections/vec2.rs b/exercises/collections/vec2.rs index 6595e401..c88ff4b9 100644 --- a/exercises/collections/vec2.rs +++ b/exercises/collections/vec2.rs @@ -7,10 +7,13 @@ // Execute the command `rustlings hint vec2` if you need // hints. -// I AM NOT DONE fn vec_loop(mut v: Vec) -> Vec { for i in v.iter_mut() { + println!("{}",i); + *i=*i*2; + println!("{}",i); + // TODO: Fill this up so that each element in the Vec `v` is // multiplied by 2. } @@ -26,8 +29,8 @@ mod tests { #[test] fn test_vec_loop() { let v: Vec = (1..).filter(|x| x % 2 == 0).take(5).collect(); + let v2:Vec=(1..13).collect(); let ans = vec_loop(v.clone()); - assert_eq!(ans, v.iter().map(|x| x * 2).collect::>()); } }