deduplicate code in rotate method
This commit is contained in:
parent
9a9bad4f71
commit
95d201eb2f
17
src/main.rs
17
src/main.rs
@ -44,18 +44,19 @@ mod rover {
|
||||
|
||||
pub fn rotate(&self, rotation: Rotation) -> Rover {
|
||||
let Rover(lon, lat, direction) = self;
|
||||
match rotation {
|
||||
let new_direction = match rotation {
|
||||
Rotation::Left => {
|
||||
let new_d = next_direction(*direction);
|
||||
Rover(*lon, *lat, new_d)
|
||||
next_direction(*direction)
|
||||
},
|
||||
Rotation::Right => {
|
||||
let new_d = next_direction(*direction);
|
||||
let new_d = next_direction(new_d);
|
||||
let new_d = next_direction(new_d);
|
||||
Rover(*lon, *lat, new_d)
|
||||
next_direction(
|
||||
next_direction(
|
||||
next_direction(*direction)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
};
|
||||
Rover(*lon, *lat, new_direction)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user