From 6d2dc6d7f68381a3fbe4503db005f95ded99fdba Mon Sep 17 00:00:00 2001
From: lukaszKielar <kielar.lukasz@hotmail.com>
Date: Thu, 25 Jun 2020 22:07:34 +0200
Subject: [PATCH] finish option exercises

---
 exercises/option/option1.rs | 12 ++++--------
 exercises/option/option2.rs |  8 +++-----
 2 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/exercises/option/option1.rs b/exercises/option/option1.rs
index 602ff1a..a3c3e07 100644
--- a/exercises/option/option1.rs
+++ b/exercises/option/option1.rs
@@ -1,22 +1,18 @@
 // option1.rs
 // Make me compile! Execute `rustlings hint option1` for hints
 
-// I AM NOT DONE
-
 // you can modify anything EXCEPT for this function's sig
 fn print_number(maybe_number: Option<u16>) {
     println!("printing: {}", maybe_number.unwrap());
 }
 
 fn main() {
-    print_number(13);
-    print_number(99);
+    print_number(Some(13));
+    print_number(Some(99));
 
-    let mut numbers: [Option<u16>; 5];
+    let mut numbers: [u16; 5] = [0; 5];
     for iter in 0..5 {
-        let number_to_add: u16 = {
-            ((iter * 1235) + 2) / (4 * 16)
-        };
+        let number_to_add: u16 = { ((iter * 1235) + 2) / (4 * 16) };
 
         numbers[iter as usize] = number_to_add;
     }
diff --git a/exercises/option/option2.rs b/exercises/option/option2.rs
index a1517d7..ce5542d 100644
--- a/exercises/option/option2.rs
+++ b/exercises/option/option2.rs
@@ -1,12 +1,10 @@
 // option2.rs
 // Make me compile! Execute `rustlings hint option2` for hints
 
-// I AM NOT DONE
-
 fn main() {
     let optional_value = Some(String::from("rustlings"));
     // TODO: Make this an if let statement whose value is "Some" type
-    value = optional_value {
+    if let Some(value) = optional_value {
         println!("the value of optional value is: {}", value);
     } else {
         println!("The optional value doesn't contain anything!");
@@ -19,7 +17,7 @@ fn main() {
 
     // TODO: make this a while let statement - remember that vector.pop also adds another layer of Option<T>
     // You can stack `Option<T>`'s into while let and if let
-    value = optional_values_vec.pop() {
-        println!("current value: {}", value);
+    while let Some(value) = optional_values_vec.pop() {
+        println!("current value: {}", value.unwrap());
     }
 }