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 fix(rust-piscine) adding a new file for code editor to use 6 months ago
..
README.md feat(organize_garage): add new exercise for rust exams 1 year ago
main.rs fix(rust-piscine) adding a new file for code editor to use 6 months ago

README.md

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.

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 }
$