diff options
Diffstat (limited to 'exercises/06_move_semantics/move_semantics3.rs')
| -rw-r--r-- | exercises/06_move_semantics/move_semantics3.rs | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/exercises/06_move_semantics/move_semantics3.rs b/exercises/06_move_semantics/move_semantics3.rs index 7af9e69..11dbbbe 100644 --- a/exercises/06_move_semantics/move_semantics3.rs +++ b/exercises/06_move_semantics/move_semantics3.rs @@ -1,24 +1,22 @@ -// move_semantics3.rs -// -// Make me compile without adding new lines -- just changing existing lines! (no -// lines with multiple semicolons necessary!) -// -// Execute `rustlings hint move_semantics3` or use the `hint` watch subcommand -// for a hint. +// TODO: Fix the compiler error in the function without adding any new line. +fn fill_vec(vec: Vec<i32>) -> Vec<i32> { + vec.push(88); -// I AM NOT DONE + vec +} -#[test] fn main() { - let vec0 = vec![22, 44, 66]; - - let mut vec1 = fill_vec(vec0); - - assert_eq!(vec1, vec![22, 44, 66, 88]); + // You can optionally experiment here. } -fn fill_vec(vec: Vec<i32>) -> Vec<i32> { - vec.push(88); +#[cfg(test)] +mod tests { + use super::*; - vec + #[test] + fn move_semantics3() { + let vec0 = vec![22, 44, 66]; + let vec1 = fill_vec(vec0); + assert_eq!(vec1, [22, 44, 66, 88]); + } } |
