Complete the signature and the body of the `str_len` that receives a string or a string literal and returns its length without taking ownership of the value (i.e, borrowing the value)
Complete the signature and the body of the `str_len`**function**that receives a string or a string literal and returns its length without taking ownership of the value (i.e, borrowing the value).
### Expected Function
### Expected Function (The signature needs to be completed)
```rust
```rust
pub fn str_len(s: ) -> usize {
pub fn str_len(s: ) -> usize {
}
}
```
```
### Notions
[Primitive Type str](https://doc.rust-lang.org/std/primitive.str.html)
@ -7,7 +7,11 @@ needing garbage collector. Therefore you must understand ownership in rust.
Create the following functions :
Create the following functions :
- `delete_and_backspace`, imagine that `-` represents the backspace key and the `+` represents the delete key, this function must receive a borrowed string and turn this string into the string without the backspaces and the deletes.
- `delete_and_backspace`, imagine that the `-` represents the `backspace key` and the `+` represents the `delete key`, this function must receive a borrowed string and turn this string into the string that applies the `backspaces` and the `deletes`.
- For example:
- "helll-o" turns into "hello"
- "he+lllo" turns into "hello"
- `is_correct` that borrows a Vector of string literals with some correct and incorrect math equations and replaces the correct equations with `✔` and the wrong with `✘` and returns a `usize` with the percentage of correct equations.
- `is_correct` that borrows a Vector of string literals with some correct and incorrect math equations and replaces the correct equations with `✔` and the wrong with `✘` and returns a `usize` with the percentage of correct equations.
Imagine you are working in a software to control smart lights in a house. You have access to an array of all the lights in a house.
Imagine you are working on a software to control smart lights in a house. You have access to an array of all the lights in a house.
Define the associated function `new` to the data structure `Light` which creates a new light with the alias passed in the arguments and a brightness of 0.
Define the associated **function**`new` to the data structure `Light` which creates a new light with the alias passed in the arguments and a brightness of 0.
Define the function `change_brightness` that receives a Vec of lights, an alias and a u8 value and sets the u8 value as the new brightness of the light identified by the alias in the Vec of lights.
Define the **function**`change_brightness` that receives a `Vec` of lights, an `alias` and a `u8`value. The **function** then sets the `u8` value as the new brightness of the light identified by the alias in the Vec of lights.
### Notions
[Example of Structs](https://doc.rust-lang.org/book/ch05-02-example-structs.html)
- `tic_tac_toe` that receives a table of vectors (Vec<Vec<&str>>) and returns a string : `player O won` or `player X won` or `Tie`
- `tic_tac_toe` which receives:
- `diagonals` that will receive a player and a table. It should return a boolean, this must return true if all the diagonals are completed by the player
- a table of vectors (Vec<Vec<&str>>).
- `horizontal` that will receive a player and a table. It should return a boolean, this must return true if one of the horizontal lines are completed by the player
- It should return a String `player O won` or `player X won` or `Tie`.
- `vertical` that will receive a player and a table. It should return a boolean, this must return true if one of the vertical lines are completed by the player
- `diagonals` which will receive:
- a player and a table.
- It should return a boolean, this must return `true` if all the diagonals are completed by the player.
- `horizontal` which will receive:
- a player and a table.
- It should return a boolean, this must return `true` if one of the horizontal lines are completed by the player.
- `vertical` which will receive:
- a player and a table.
- It should return a boolean, this must return `true` if one of the vertical lines are completed by the player.