From e388f8a1d497a2bd10c4805289bbe1728dc43672 Mon Sep 17 00:00:00 2001
From: 0xChasingFire <0xchasingfire@gmail.com>
Date: Fri, 21 May 2021 16:41:05 +0800
Subject: [PATCH] enum and modules

---
 exercises/enums/enums1.rs                   |  6 ++++--
 exercises/enums/enums2.rs                   |  6 ++++--
 exercises/enums/enums3.rs                   | 12 ++++++++++--
 exercises/modules/modules1.rs               |  5 ++---
 exercises/modules/modules2.rs               |  8 +++-----
 exercises/move_semantics/move_semantics5.rs | 10 ++++++----
 6 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/exercises/enums/enums1.rs b/exercises/enums/enums1.rs
index a2223d3..2baa8f2 100644
--- a/exercises/enums/enums1.rs
+++ b/exercises/enums/enums1.rs
@@ -1,11 +1,13 @@
 // enums1.rs
 // Make me compile! Execute `rustlings hint enums1` for hints!
 
-// I AM NOT DONE
-
 #[derive(Debug)]
 enum Message {
     // TODO: define a few types of messages as used below
+    Quit,
+    Echo,
+    Move,
+    ChangeColor,
 }
 
 fn main() {
diff --git a/exercises/enums/enums2.rs b/exercises/enums/enums2.rs
index ec32d95..f84ff4f 100644
--- a/exercises/enums/enums2.rs
+++ b/exercises/enums/enums2.rs
@@ -1,11 +1,13 @@
 // enums2.rs
 // Make me compile! Execute `rustlings hint enums2` for hints!
 
-// I AM NOT DONE
-
 #[derive(Debug)]
 enum Message {
     // TODO: define the different variants used below
+    Move{x: i32, y: i32},
+    Echo(String),
+    ChangeColor(i32, i32, i32),
+    Quit,
 }
 
 impl Message {
diff --git a/exercises/enums/enums3.rs b/exercises/enums/enums3.rs
index 178b40c..402ddca 100644
--- a/exercises/enums/enums3.rs
+++ b/exercises/enums/enums3.rs
@@ -1,10 +1,12 @@
 // enums3.rs
 // Address all the TODOs to make the tests pass!
 
-// I AM NOT DONE
-
 enum Message {
     // TODO: implement the message variant types based on their usage below
+    Move(Point),
+    Echo(String),
+    ChangeColor((u8, u8, u8)),
+    Quit,
 }
 
 struct Point {
@@ -37,6 +39,12 @@ impl State {
 
     fn process(&mut self, message: Message) {
         // TODO: create a match expression to process the different message variants
+        match message {
+            Message::ChangeColor(color) => self.change_color(color),
+            Message::Move(point) => self.move_position(point),
+            Message::Echo(string) => self.echo(string), 
+            Message::Quit => self.quit(),
+        }
     }
 }
 
diff --git a/exercises/modules/modules1.rs b/exercises/modules/modules1.rs
index 812dfee..f0c8b0f 100644
--- a/exercises/modules/modules1.rs
+++ b/exercises/modules/modules1.rs
@@ -1,10 +1,9 @@
 // modules1.rs
 // Make me compile! Execute `rustlings hint modules1` for hints :)
 
-// I AM NOT DONE
 
-mod sausage_factory {
-    fn make_sausage() {
+pub mod sausage_factory {
+    pub fn make_sausage() {
         println!("sausage!");
     }
 }
diff --git a/exercises/modules/modules2.rs b/exercises/modules/modules2.rs
index fde439d..0181caa 100644
--- a/exercises/modules/modules2.rs
+++ b/exercises/modules/modules2.rs
@@ -1,11 +1,9 @@
 // modules2.rs
 // Make me compile! Execute `rustlings hint modules2` for hints :)
 
-// I AM NOT DONE
-
-mod delicious_snacks {
-    use self::fruits::PEAR as fruit;
-    use self::veggies::CUCUMBER as veggie;
+pub mod delicious_snacks {
+    pub use self::fruits::PEAR as fruit;
+    pub use self::veggies::CUCUMBER as veggie;
 
     mod fruits {
         pub const PEAR: &'static str = "Pear";
diff --git a/exercises/move_semantics/move_semantics5.rs b/exercises/move_semantics/move_semantics5.rs
index 4f8128c..99aa9cd 100644
--- a/exercises/move_semantics/move_semantics5.rs
+++ b/exercises/move_semantics/move_semantics5.rs
@@ -2,13 +2,15 @@
 // Make me compile without adding any newlines or removing any of the lines.
 // Execute `rustlings hint move_semantics5` for hints :)
 
-// I AM NOT DONE
 
 fn main() {
     let mut x = 100;
-    let y = &mut x;
-    let z = &mut *y;
-    *y += 100;
+    {
+        let y = &mut x;
+        *y += 100;
+    }
+    let z = &mut x;
+    // *y += 100;
     *z += 1000;
     assert_eq!(x, 1200);
 }