rustlings

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

move_semantics1.rs (414B)


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