Browse Source

feat(organize_garage): add new exercise for rust exams

DEV-3972-prepare-blockchain-branch-subjects
mikysett 2 years ago committed by Michele
parent
commit
61673c3614
  1. 44
      subjects/organize_garage/README.md

44
subjects/organize_garage/README.md

@ -0,0 +1,44 @@
## organize_garage
### Instructions
Create a structure `Garage` with generic values. It will have the following public fields:
- `left` as `Option<T>`.
- `right` as `Option<T>`.
It will implement the following public methods:
- `move_to_right`: Moves the values from left to right.
- `move_to_left`: Moves the values from right to left.
> The generic type will need to have `Add` and `Copy` traits implemented. It will also need to derive `Debug`.
### Usage
Here is a program to test your function.
```rust
use organize_garage::*;
fn main() {
let mut garage = Garage {
left: Some(5),
right: Some(2),
};
println!("{:?}", garage);
garage.move_to_right();
println!("{:?}", garage);
garage.move_to_left();
println!("{:?}", garage);
}
```
And its output
```console
$ cargo run
Garage { left: Some(5), right: Some(2) }
Garage { left: None, right: Some(7) }
Garage { left: Some(7), right: None }
$
```
Loading…
Cancel
Save