From 1d186e5644a78c0938f16327c9b224f13795e9ec Mon Sep 17 00:00:00 2001
From: Eri Mendz <erimendz@gmail.com>
Date: Tue, 25 May 2021 14:47:39 +0300
Subject: [PATCH] add solutions to exercises move_semantics

---
 exercises/move_semantics/move_semantics2.rs | 11 ++++++++---
 exercises/move_semantics/move_semantics3.rs |  8 ++++++--
 exercises/move_semantics/move_semantics4.rs | 10 ++++++----
 3 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/exercises/move_semantics/move_semantics2.rs b/exercises/move_semantics/move_semantics2.rs
index bd21fbb..c51d01f 100644
--- a/exercises/move_semantics/move_semantics2.rs
+++ b/exercises/move_semantics/move_semantics2.rs
@@ -2,18 +2,23 @@
 // Make me compile without changing line 13!
 // Execute `rustlings hint move_semantics2` for hints :)
 
-// I AM NOT DONE
+// done may 25
 
 fn main() {
+	// make empty Vec
     let vec0 = Vec::new();
 
-    let mut vec1 = fill_vec(vec0);
+	// make vec1 as clone of vec0 and run the function fill_vec
+    let mut vec1 = fill_vec(vec0.clone());
 
     // Do not change the following line!
     println!("{} has length {} content `{:?}`", "vec0", vec0.len(), vec0);
 
-    vec1.push(88);
+    // before push of last element
+    println!("{} has length {} content `{:?}`", "vec1", vec1.len(), vec1);
 
+	// after push of last element
+    vec1.push(88);
     println!("{} has length {} content `{:?}`", "vec1", vec1.len(), vec1);
 }
 
diff --git a/exercises/move_semantics/move_semantics3.rs b/exercises/move_semantics/move_semantics3.rs
index 43fef74..754419e 100644
--- a/exercises/move_semantics/move_semantics3.rs
+++ b/exercises/move_semantics/move_semantics3.rs
@@ -3,11 +3,12 @@
 // (no lines with multiple semicolons necessary!)
 // Execute `rustlings hint move_semantics3` for hints :)
 
-// I AM NOT DONE
+// DONE May 25/21
 
 fn main() {
     let vec0 = Vec::new();
 
+	// make call to function fill_vec
     let mut vec1 = fill_vec(vec0);
 
     println!("{} has length {} content `{:?}`", "vec1", vec1.len(), vec1);
@@ -15,9 +16,12 @@ fn main() {
     vec1.push(88);
 
     println!("{} has length {} content `{:?}`", "vec1", vec1.len(), vec1);
+    vec1.pop(); //remove last element of vec
+    println!("{} has length {} content `{:?}`", "vec1", vec1.len(), vec1);
 }
 
-fn fill_vec(vec: Vec<i32>) -> Vec<i32> {
+// add mut keyword to vec
+fn fill_vec(mut vec: Vec<i32>) -> Vec<i32> {
     vec.push(22);
     vec.push(44);
     vec.push(66);
diff --git a/exercises/move_semantics/move_semantics4.rs b/exercises/move_semantics/move_semantics4.rs
index a1c4a41..2afbeba 100644
--- a/exercises/move_semantics/move_semantics4.rs
+++ b/exercises/move_semantics/move_semantics4.rs
@@ -4,12 +4,14 @@
 // freshly created vector from fill_vec to its caller.
 // Execute `rustlings hint move_semantics4` for hints!
 
-// I AM NOT DONE
+// may 25/21 DONE
 
 fn main() {
-    let vec0 = Vec::new();
+	// disabled the below line and mv inside the function, see above comments
+    //let vec0 = Vec::new();
 
-    let mut vec1 = fill_vec(vec0);
+    //let mut vec1 = fill_vec(vec0);
+    let mut vec1 = fill_vec();
 
     println!("{} has length {} content `{:?}`", "vec1", vec1.len(), vec1);
 
@@ -20,7 +22,7 @@ fn main() {
 
 // `fill_vec()` no longer take `vec: Vec<i32>` as argument
 fn fill_vec() -> Vec<i32> {
-    let mut vec = vec;
+    let mut vec = Vec::new();
 
     vec.push(22);
     vec.push(44);