rustlings

solving rustlings ft. dracuxan
git clone [email protected]:dracuxan/rustlings.git
Log | Files | Refs

move_semantics3.rs (417B)


      1 // TODO: Fix the compiler error in the function without adding any new line.
      2 fn fill_vec(mut vec: Vec<i32>) -> Vec<i32> {
      3     vec.push(88);
      4 
      5     vec
      6 }
      7 
      8 fn main() {
      9     // You can optionally experiment here.
     10 }
     11 
     12 #[cfg(test)]
     13 mod tests {
     14     use super::*;
     15 
     16     #[test]
     17     fn move_semantics3() {
     18         let vec0 = vec![22, 44, 66];
     19         let vec1 = fill_vec(vec0);
     20         assert_eq!(vec1, [22, 44, 66, 88]);
     21     }
     22 }