@@ -77,8 +77,7 @@ pub fn next_heuristic<'h>(
7777 heuristics : & ' h [ Box < dyn Heuristic > ] ,
7878) -> Option < & ' h dyn Heuristic > {
7979 debug ! (
80- "Generating next heuristic with {:?} strategy" ,
81- solve_strategy
80+ "Generating next heuristic with {solve_strategy:?} strategy"
8281 ) ;
8382 let h = match solve_strategy {
8483 SolveStrategy :: Short => heuristics
@@ -127,7 +126,7 @@ pub fn all_heuristics(board: &Board) -> Vec<Box<dyn Heuristic>> {
127126 v. extend ( board. all_colors ( ) . iter ( ) . map ( |color| {
128127 Box :: new ( LastSquareAvailable {
129128 coords : board. coords_for_color ( color) ,
130- desc : format ! ( "'{:?}' Color" , color ) ,
129+ desc : format ! ( "'{color :?}' Color" ) ,
131130 } ) as _
132131 } ) ) ;
133132 v. extend ( ( 0 ..board. size ( ) ) . map ( |r| {
@@ -157,7 +156,7 @@ pub fn all_heuristics(board: &Board) -> Vec<Box<dyn Heuristic>> {
157156 v. extend ( board. all_colors ( ) . into_iter ( ) . map ( |color| {
158157 Box :: new ( AllPossibilitiesEliminateSquare {
159158 coords : board. coords_for_color ( color) ,
160- desc : format ! ( "'{:?}' Color" , color ) ,
159+ desc : format ! ( "'{color :?}' Color" ) ,
161160 } ) as _
162161 } ) ) ;
163162
@@ -186,7 +185,7 @@ pub fn all_heuristics(board: &Board) -> Vec<Box<dyn Heuristic>> {
186185 . filter ( |cc| !cc. is_empty ( ) )
187186 . map ( |cc| {
188187 Box :: new ( NColorsOnlyAppearInNLines {
189- color_desc : format ! ( "{:?}" , cc ) ,
188+ color_desc : format ! ( "{cc :?}" ) ,
190189 colors : SquareColorSet :: from_iter ( cc. into_iter ( ) . copied ( ) ) ,
191190 liner : |coord| coord. 0 ,
192191 liner_desc : "rows" . to_string ( ) ,
@@ -201,7 +200,7 @@ pub fn all_heuristics(board: &Board) -> Vec<Box<dyn Heuristic>> {
201200 . filter ( |cc| !cc. is_empty ( ) )
202201 . map ( |cc| {
203202 Box :: new ( NColorsOnlyAppearInNLines {
204- color_desc : format ! ( "{:?}" , cc ) ,
203+ color_desc : format ! ( "{cc :?}" ) ,
205204 colors : SquareColorSet :: from_iter ( cc. into_iter ( ) . copied ( ) ) ,
206205 liner : |coord| coord. 1 ,
207206 liner_desc : "cols" . to_string ( ) ,
@@ -223,22 +222,22 @@ impl Heuristic for LastSquareAvailable {
223222 self . coords
224223 }
225224 fn changes ( & self , solve_state : & SolveState ) -> Option < Changes > {
226- trace ! ( "Heuristic Start: LastSquareAvailable {:?}" , self ) ;
225+ trace ! ( "Heuristic Start: LastSquareAvailable {self :?}" ) ;
227226 let last_empty_coord = self
228227 . coords
229228 . iter ( )
230229 . filter ( |& c| solve_state. square ( & c) . is_none ( ) )
231230 . exactly_one ( )
232231 . ok ( ) ;
233232 let queen = last_empty_coord?;
234- trace ! ( "Heuristic Success: LastSquareAvailable {:?}" , self ) ;
233+ trace ! ( "Heuristic Success: LastSquareAvailable {self :?}" ) ;
235234 let x = solve_state
236235 . board
237236 . queen_borders ( & queen)
238237 . iter ( )
239238 . filter ( |& coord| solve_state. square ( & coord) . is_none ( ) )
240239 . collect :: < CoordSet > ( ) ;
241- trace ! ( "Heuristic Return: LastSquareAvailable {:?}" , self ) ;
240+ trace ! ( "Heuristic Return: LastSquareAvailable {self :?}" ) ;
242241 Some ( Changes :: AddQueen { queen, x } )
243242 }
244243
@@ -265,8 +264,7 @@ impl Heuristic for AllPossibilitiesEliminateSquare {
265264 }
266265 fn changes ( & self , solve_state : & SolveState ) -> Option < Changes > {
267266 trace ! (
268- "Heuristic Start: AllPossibilitiesEliminateSquare {:?}" ,
269- self
267+ "Heuristic Start: AllPossibilitiesEliminateSquare {self:?}"
270268 ) ;
271269 let x = self
272270 . coords
@@ -282,8 +280,7 @@ impl Heuristic for AllPossibilitiesEliminateSquare {
282280 None
283281 } else {
284282 trace ! (
285- "Heuristic Success/Return: AllPossibilitiesEliminateSquare {:?}" ,
286- self
283+ "Heuristic Success/Return: AllPossibilitiesEliminateSquare {self:?}"
287284 ) ;
288285 Some ( Changes :: AddX { x } )
289286 }
@@ -312,14 +309,14 @@ impl Heuristic for NLinesContainOnlyNColors {
312309 . collect ( )
313310 }
314311 fn changes ( & self , solve_state : & SolveState ) -> Option < Changes > {
315- trace ! ( "Heuristic Start: NLinesContainOnlyNColors {:?}" , self ) ;
312+ trace ! ( "Heuristic Start: NLinesContainOnlyNColors {self :?}" ) ;
316313 if self
317314 . lines
318315 . iter ( )
319316 . flatten ( )
320317 . any ( |coord| solve_state. square ( & coord) == Some ( SquareVal :: Queen ) )
321318 {
322- trace ! ( "Heuristic Invalid: NLinesContainOnlyNColors {:?}" , self ) ;
319+ trace ! ( "Heuristic Invalid: NLinesContainOnlyNColors {self :?}" ) ;
323320 return None ;
324321 }
325322 let coords = CoordSet :: from_iter (
@@ -331,10 +328,10 @@ impl Heuristic for NLinesContainOnlyNColors {
331328 let colors_set =
332329 SquareColorSet :: from_iter ( coords. iter ( ) . map ( |coord| solve_state. board . color ( & coord) ) ) ;
333330 if colors_set. len ( ) > self . lines . len ( ) {
334- trace ! ( "Heuristic Invalid: NLinesContainOnlyNColors {:?}" , self ) ;
331+ trace ! ( "Heuristic Invalid: NLinesContainOnlyNColors {self :?}" ) ;
335332 return None ;
336333 }
337- trace ! ( "Heuristic Success: NLinesContainOnlyNColors {:?}" , self ) ;
334+ trace ! ( "Heuristic Success: NLinesContainOnlyNColors {self :?}" ) ;
338335 let x = solve_state
339336 . board
340337 . all_coords ( )
@@ -344,10 +341,10 @@ impl Heuristic for NLinesContainOnlyNColors {
344341 . filter ( |coord| solve_state. square ( coord) . is_none ( ) )
345342 . collect :: < CoordSet > ( ) ;
346343 if x. is_empty ( ) {
347- trace ! ( "Heuristic No-op: NLinesContainOnlyNColors {:?}" , self ) ;
344+ trace ! ( "Heuristic No-op: NLinesContainOnlyNColors {self :?}" ) ;
348345 None
349346 } else {
350- trace ! ( "Heuristic Return: NLinesContainOnlyNColors {:?}" , self ) ;
347+ trace ! ( "Heuristic Return: NLinesContainOnlyNColors {self :?}" ) ;
351348 Some ( Changes :: AddX { x } )
352349 }
353350 }
@@ -380,15 +377,15 @@ impl Heuristic for NColorsOnlyAppearInNLines {
380377 . collect ( )
381378 }
382379 fn changes ( & self , solve_state : & SolveState ) -> Option < Changes > {
383- trace ! ( "Heuristic Start: NLinesContainOnlyNColors {:?}" , self ) ;
380+ trace ! ( "Heuristic Start: NLinesContainOnlyNColors {self :?}" ) ;
384381 if solve_state
385382 . board
386383 . all_coords ( )
387384 . iter ( )
388385 . filter ( |coord| self . colors . contains ( & solve_state. board . color ( coord) ) )
389386 . any ( |coord| solve_state. square ( & coord) == Some ( SquareVal :: Queen ) )
390387 {
391- trace ! ( "Heuristic Invalid: NLinesContainOnlyNColors {:?}" , self ) ;
388+ trace ! ( "Heuristic Invalid: NLinesContainOnlyNColors {self :?}" ) ;
392389 return None ;
393390 }
394391 let coords = solve_state. board . all_coords ( ) ;
@@ -399,10 +396,10 @@ impl Heuristic for NColorsOnlyAppearInNLines {
399396 . map ( self . liner ) ;
400397 let lines_set = LineSet :: from_iter ( lines) ;
401398 if lines_set. len ( ) > self . colors . len ( ) {
402- trace ! ( "Heuristic Invalid: NLinesContainOnlyNColors {:?}" , self ) ;
399+ trace ! ( "Heuristic Invalid: NLinesContainOnlyNColors {self :?}" ) ;
403400 return None ;
404401 }
405- trace ! ( "Heuristic Success: NLinesContainOnlyNColors {:?}" , self ) ;
402+ trace ! ( "Heuristic Success: NLinesContainOnlyNColors {self :?}" ) ;
406403 let x = solve_state
407404 . board
408405 . all_coords ( )
@@ -412,10 +409,10 @@ impl Heuristic for NColorsOnlyAppearInNLines {
412409 . filter ( |coord| solve_state. square ( coord) . is_none ( ) )
413410 . collect :: < CoordSet > ( ) ;
414411 if x. is_empty ( ) {
415- trace ! ( "Heuristic No-op: NLinesContainOnlyNColors {:?}" , self ) ;
412+ trace ! ( "Heuristic No-op: NLinesContainOnlyNColors {self :?}" ) ;
416413 None
417414 } else {
418- trace ! ( "Heuristic Return: NLinesContainOnlyNColors {:?}" , self ) ;
415+ trace ! ( "Heuristic Return: NLinesContainOnlyNColors {self :?}" ) ;
419416 Some ( Changes :: AddX { x } )
420417 }
421418 }
0 commit comments