|
|
@ -3,10 +3,12 @@ |
|
|
|
### Instructions |
|
|
|
### Instructions |
|
|
|
|
|
|
|
|
|
|
|
Create a function called `choose_outfit` that receives the following input: |
|
|
|
Create a function called `choose_outfit` that receives the following input: |
|
|
|
|
|
|
|
|
|
|
|
- A `formality_level` as an `Option<u32>`. |
|
|
|
- A `formality_level` as an `Option<u32>`. |
|
|
|
- An `invitation_message` as a `Result<&str>`. |
|
|
|
- An `invitation_message` as a `Result<&str>`. |
|
|
|
|
|
|
|
|
|
|
|
The function will return a struct `Outfit` which contains: |
|
|
|
The function will return a struct `Outfit` which contains: |
|
|
|
|
|
|
|
|
|
|
|
- `jacket`, an `enum` `Jacket` that contains `Black`, `White` and `Flowers`. |
|
|
|
- `jacket`, an `enum` `Jacket` that contains `Black`, `White` and `Flowers`. |
|
|
|
- `hat`, an `enum` `Hat` that contains `Snapback`, `Baseball`, `Fedora`. |
|
|
|
- `hat`, an `enum` `Hat` that contains `Snapback`, `Baseball`, `Fedora`. |
|
|
|
|
|
|
|
|
|
|
@ -19,18 +21,20 @@ pub struct Outfit { |
|
|
|
``` |
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
For the `jacket`: |
|
|
|
For the `jacket`: |
|
|
|
|
|
|
|
|
|
|
|
- The jacket should be `Flowers` when the `formality_level` is unset. |
|
|
|
- The jacket should be `Flowers` when the `formality_level` is unset. |
|
|
|
- The jacket should be `White` when the `formality_level` is more than 0. |
|
|
|
- The jacket should be `White` when the `formality_level` is more than 0. |
|
|
|
- Otherwise, it should be `Black`. |
|
|
|
- Otherwise, it should be `Black`. |
|
|
|
|
|
|
|
|
|
|
|
For the `hat`: |
|
|
|
For the `hat`: |
|
|
|
|
|
|
|
|
|
|
|
- If the `invitation_message` is `Ok()` it should be `Fedora`. |
|
|
|
- If the `invitation_message` is `Ok()` it should be `Fedora`. |
|
|
|
- Otherwise, it should be `Snapback`. |
|
|
|
- Otherwise, it should be `Snapback`. |
|
|
|
|
|
|
|
|
|
|
|
In the specific case where `formality_level` is `None` and `invitation_message` |
|
|
|
In the specific case where `formality_level` is `None` and `invitation_message` |
|
|
|
is not `Ok()` then the `jacket` should be `Flowers` and the `hat` should be `Baseball`. |
|
|
|
is not `Ok()` then the `jacket` should be `Flowers` and the `hat` should be `Baseball`. |
|
|
|
|
|
|
|
|
|
|
|
Remember that all the `enum` and `struct` used must be `pub`. |
|
|
|
Remember that all the `enum` and `struct` used must be `pub`. |
|
|
|
|
|
|
|
|
|
|
|
### Expected functions |
|
|
|
### Expected functions |
|
|
|
|
|
|
|
|
|
|
@ -51,6 +55,7 @@ fn main() { |
|
|
|
``` |
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
And its output: |
|
|
|
And its output: |
|
|
|
|
|
|
|
|
|
|
|
```console |
|
|
|
```console |
|
|
|
$ cargo run |
|
|
|
$ cargo run |
|
|
|
My outfit will be: Outfit { jacket: Black, hat: Fedora } |
|
|
|
My outfit will be: Outfit { jacket: Black, hat: Fedora } |
|
|
|