mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
miguel
1aa3484757
|
1 year ago | |
---|---|---|
.. | ||
README.md | ||
main.rs | 1 year ago |
README.md
organize_garage
Instructions
Create a structure Garage
with generic values. It will have the following public fields:
left
asOption<T>
.right
asOption<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
andCopy
traits implemented. It will also need to deriveDebug
.
Usage
Here is a program to test your function.
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
$ cargo run
Garage { left: Some(5), right: Some(2) }
Garage { left: None, right: Some(7) }
Garage { left: Some(7), right: None }
$