@@ -17,24 +17,24 @@ impl Point {
1717 Point :: new ( self . x + p. x , self . y + p. y )
1818 }
1919
20- pub fn move_with ( & self , command : Command ) -> Point {
20+ pub fn move_with ( & self , kind : & Move ) -> Point {
2121 let ( x, y) = ( self . x , self . y ) ;
22- match command {
23- Command :: MoveUp => Point :: new ( x, y + 1 ) ,
24- Command :: MoveDown => Point :: new ( x, y - 1 ) ,
25- Command :: MoveRight => Point :: new ( x + 1 , y) ,
26- Command :: MoveLeft => Point :: new ( x - 1 , y) ,
22+ match kind {
23+ Move :: MoveUp => Point :: new ( x, y + 1 ) ,
24+ Move :: MoveDown => Point :: new ( x, y - 1 ) ,
25+ Move :: MoveRight => Point :: new ( x + 1 , y) ,
26+ Move :: MoveLeft => Point :: new ( x - 1 , y) ,
2727 _ => * self ,
2828 }
2929 }
3030
31- pub fn revert_with ( & self , command : Command ) -> Point {
31+ pub fn revert_with ( & self , kind : & Move ) -> Point {
3232 let ( x, y) = ( self . x , self . y ) ;
33- match command {
34- Command :: MoveUp => Point :: new ( x, y - 1 ) ,
35- Command :: MoveDown => Point :: new ( x, y + 1 ) ,
36- Command :: MoveRight => Point :: new ( x - 1 , y) ,
37- Command :: MoveLeft => Point :: new ( x + 1 , y) ,
33+ match kind {
34+ Move :: MoveUp => Point :: new ( x, y - 1 ) ,
35+ Move :: MoveDown => Point :: new ( x, y + 1 ) ,
36+ Move :: MoveRight => Point :: new ( x - 1 , y) ,
37+ Move :: MoveLeft => Point :: new ( x + 1 , y) ,
3838 _ => unreachable ! ( ) ,
3939 }
4040 }
@@ -99,7 +99,7 @@ impl Map {
9999 }
100100}
101101
102- #[ derive( Debug , Clone , Copy ) ]
102+ #[ derive( Debug , Clone ) ]
103103pub enum BoosterType {
104104 NewHand ,
105105 FastMove ,
@@ -109,7 +109,7 @@ pub enum BoosterType {
109109 Unknown ,
110110}
111111
112- #[ derive( Debug , Clone , Copy ) ]
112+ #[ derive( Debug , Clone ) ]
113113pub struct Booster {
114114 pub kind : BoosterType ,
115115 pub point : Point ,
@@ -129,13 +129,18 @@ pub struct Task {
129129 pub boosters : Vec < Booster > ,
130130}
131131
132- #[ derive( Debug , Clone , Copy ) ]
133- pub enum Command {
132+ #[ derive( Debug , Clone ) ]
133+ pub enum Move {
134134 MoveUp ,
135135 MoveDown ,
136136 MoveLeft ,
137137 MoveRight ,
138- Noop ,
138+ Noop
139+ }
140+
141+ #[ derive( Debug , Clone ) ]
142+ pub enum Command {
143+ Move ( Move ) ,
139144 TurnRight ,
140145 TurnLeft ,
141146 NewHand ( Point ) ,
@@ -144,11 +149,11 @@ pub enum Command {
144149impl fmt:: Display for Command {
145150 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
146151 match self {
147- Command :: MoveUp => write ! ( f, "W" ) ,
148- Command :: MoveDown => write ! ( f, "S" ) ,
149- Command :: MoveLeft => write ! ( f, "A" ) ,
150- Command :: MoveRight => write ! ( f, "D" ) ,
151- Command :: Noop => write ! ( f, "Z" ) ,
152+ Command :: Move ( Move :: MoveUp ) => write ! ( f, "W" ) ,
153+ Command :: Move ( Move :: MoveDown ) => write ! ( f, "S" ) ,
154+ Command :: Move ( Move :: MoveLeft ) => write ! ( f, "A" ) ,
155+ Command :: Move ( Move :: MoveRight ) => write ! ( f, "D" ) ,
156+ Command :: Move ( Move :: Noop ) => write ! ( f, "Z" ) ,
152157 Command :: TurnRight => write ! ( f, "E" ) ,
153158 Command :: TurnLeft => write ! ( f, "Q" ) ,
154159 Command :: NewHand ( p) => write ! ( f, "B({}, {})" , p. x, p. y) ,
0 commit comments