From 8330043326b9072a176b112a09c5a076a6d82da6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Wilma=20Krutr=C3=B6k?= <wilkru-7@student.ltu.se>
Date: Wed, 4 Nov 2020 11:41:38 +0000
Subject: [PATCH] Update HOME_EXAM.md

---
 HOME_EXAM.md | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/HOME_EXAM.md b/HOME_EXAM.md
index 40c2590..41a5203 100644
--- a/HOME_EXAM.md
+++ b/HOME_EXAM.md
@@ -597,20 +597,19 @@ Borrow is used at multiple locations, therefor it is mutable from different refe
 Below follows the rewritten examples that are accepted by the borrow checker.
 ```rust
 fn a(x: &mut i32) -> () {
-    *x += 1;
+    *x = *x + 1;
 }
 
 fn main() -> () {
     let mut y: i32 = 5;
-
     a(&mut y);
 }
 ```
 
 ```rust
 fn b(x: &mut i32, y: &mut i32) -> () {
-    *x += 1;
-    *y += 1;
+    *x = *x + 1;
+    *y = *y + 1;
 }
 fn main() -> () {
     let mut x: i32 = 5;
@@ -621,16 +620,17 @@ fn main() -> () {
 
 ```rust
 fn main() -> () {
-    let mut x = 0;
-    let y = &mut x;
-    *y += 1;
-    x += 1;
+    let mut x: i32 = 0;
+    let y: i32 = &mut x;
+    *y = *y + 1;
+    x = x + 1;
 }
 ```
 
 The borrowchecker should make sure that:
 - One reference can only be mutable at a time.
 - Multiple immutable references can be used. 
+- One mutable reference and multiple immutable references can not exist at the same time
 
 This ensures that a variable can not be changed at the same time that another reference tries to read it. 
 
@@ -648,5 +648,4 @@ The process of implementing the type checker and the interpreter was similar. Th
 
 - Code optimization and register allocation. Machine code generation for common architectures. [Both LLVM/Crane-Lift does the "dirty work" of backend optimization/register allocation leveraging the SSA form of the LLVM-IR]
 
-
-Comment on additional things that you have experienced and learned throughout the course.
+It has been difficult to write good structured code because this is the first time I worked with Rust. Therefor the rules and structure was new to me which ended up in very messy code. I focused on getting as much as possible to work to get a broad understanding instead. It would be really fun to rewrite everything from the beginning now with the knowledge and insight the course have given!
\ No newline at end of file
-- 
GitLab