You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: subjects/borrow_box/README.md
+25-27Lines changed: 25 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,13 @@ Game time.
6
6
7
7
You will implement some **CRUD** functionality for a game session. You will need to implement the `GameSession` structure with the following associated functions:
8
8
9
-
-`new`: which initializes a game session state with player names and some other information. This function returns the structure wrapped in a `Box`.
9
+
-`new`: which initializes a game session state with player names and some other information.
10
10
11
-
-`read_winner`: which returns a tuple with the name and score of the player who is currently winning. In the case that no player is winning, it should return the same tuple with the string `"Same score! tied"` and the tied score.
11
+
-`read_winner`: which returns a tuple referencing the player who is currently winning. In the case that no player is winning, it should return `None`.
12
12
13
13
-`update_score`: which receives the name of a player, and increments their score. This function should **do nothing** if the the game session is already finished or if the name received doesn't match any player.
14
14
15
-
-`delete`: which takes ownership of the boxed game session and returns a string: `"game deleted: id -> 0"`, where `0` is the id of the `GameSession`.
15
+
-`delete`: which takes ownership of the game session and returns a string: `"game deleted: id -> {id}"`, where `{id}` is the id of the `GameSession`.
16
16
17
17
> Examples for `nb_games`:
18
18
>
@@ -25,23 +25,26 @@ You will implement some **CRUD** functionality for a game session. You will need
Copy file name to clipboardExpand all lines: subjects/box_it/README.md
+21-18Lines changed: 21 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,18 +4,19 @@
4
4
5
5
Create the following **functions**:
6
6
7
-
-`transform_and_save_on_heap`: which accepts a string of numbers separated by spaces. If a number has a `'k'` as a suffix it should be multiplied by 1000. The function transforms those numbers into a vector of `u32`, and saves them in the heap using`Box`.
7
+
-`parse_into_boxed`: which accepts a string of numbers separated by spaces. If a number has a `k` as a suffix it should be multiplied by 1000. The function parses these numbers and boxes them into a vector of`Box<u32>`.
8
8
9
-
-`take_value_ownership`: which accepts the return value from `transform_and_save_on_heap`, unboxes the value, and returns it.
9
+
-`into_unboxed`: which accepts the value returned from `parse_into_boxed` and unboxes each element into another vector.
println!("size occupied in the stack : {:?} bytes", (std::mem::size_of_val(&a_b_v)));
40
-
// whenever the box, in this case "a_h", goes out of scope it will be deallocated, freed
43
+
// As with everything related to regular Rust memory management, both the `Vec` and the `Box`es will be properly dropped when out of scope and freed, ensuring no leaks
Copy file name to clipboardExpand all lines: subjects/box_recursion/README.md
+45-18Lines changed: 45 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,21 +5,32 @@
5
5
Using the given code, create the following **associated functions**:
6
6
7
7
-`new`: which will initialize the `WorkEnvironment` with `grade` set to `None`.
8
-
-`add_worker`: which receives two strings, one being the role and the other the name of the worker. It will add the worker at the start of the list.
9
-
-`remove_worker`: which removes the last worker that was placed in the `WorkEnvironment`, this function returns an `Option` with the name of the worker.
8
+
-`add_worker`: which receives a name of a worker and a role. It will add the worker at the start of the list.
9
+
-`remove_worker`: which removes the last worker that was placed in the `WorkEnvironment`, this function returns an `Option` with the name of the removed worker.
10
10
-`last_worker`: which returns an `Option` with a tuple containing the name and role of the last added worker.
11
11
12
-
You must also create a type named `Link`. This will be the connection between the `WorkEnvironment` and `Worker` structures. This will be a recursion type, and it must point to `None` if there is no `Worker` to point to.
12
+
You must also create a `Role` enum which can be `CEO`, `Manager`, or `Worker`, and will represent the role of a worker. This enum should implement the `From` trait for `&str`.
13
+
14
+
Additionally, create a type named `Link`, which will be the connection between the `WorkEnvironment` and `Worker` structures. It will point to `None` if there is no `Worker` to point to.
0 commit comments