@@ -237,8 +237,7 @@ pub struct ForcedJump {
237237/// widest at the opening and collapses quickly as pegs come off. Returns empty when `from` is
238238/// already lost - nothing is forced when nothing wins.
239239pub fn forced_jumps ( from : Board , counts : & HashMap < Board , u64 > ) -> Vec < ForcedJump > {
240- let winnable =
241- |board : & Board | counts. get ( & board. normalize ( ) ) . copied ( ) . unwrap_or ( 0 ) > 0 ;
240+ let winnable = |board : & Board | counts. get ( & board. normalize ( ) ) . copied ( ) . unwrap_or ( 0 ) > 0 ;
242241 if !winnable ( & from) {
243242 return Vec :: new ( ) ;
244243 }
@@ -256,7 +255,11 @@ pub fn forced_jumps(from: Board, counts: &HashMap<Board, u64>) -> Vec<ForcedJump
256255 // only a layer that has narrowed to one board can host a forced jump, and then only
257256 // if that board has exactly one winning move - but the sweep has to continue either
258257 // way, since a later layer may still collapse
259- let sole = if layer. len ( ) == 1 { layer. first ( ) } else { None } ;
258+ let sole = if layer. len ( ) == 1 {
259+ layer. first ( )
260+ } else {
261+ None
262+ } ;
260263 let mut only: Option < ForcedJump > = None ;
261264 let mut candidates = 0usize ;
262265
@@ -344,7 +347,8 @@ mod tests {
344347 let lines = winning_lines ( board, & set) ;
345348 assert ! ( !lines. is_empty( ) , "counts claim {board:?} is winnable" ) ;
346349 assert_eq ! (
347- lines. len( ) as u64 , counts[ & board] ,
350+ lines. len( ) as u64 ,
351+ counts[ & board] ,
348352 "brute force and the DP disagree on the line count for {board:?}"
349353 ) ;
350354
@@ -366,7 +370,10 @@ mod tests {
366370 }
367371 }
368372 assert ! ( checked > 50 , "only {checked} boards exercised" ) ;
369- assert ! ( with_forced > 0 , "no board had any forced move - test proves nothing" ) ;
373+ assert ! (
374+ with_forced > 0 ,
375+ "no board had any forced move - test proves nothing"
376+ ) ;
370377 }
371378
372379 /// Every winning line from `board` in the un-normalized game, as its list of jumps.
@@ -413,7 +420,8 @@ mod tests {
413420 for board in boards {
414421 let lines = winning_jumps ( board, & set) ;
415422 assert_eq ! (
416- lines. len( ) as u64 , counts[ & board] ,
423+ lines. len( ) as u64 ,
424+ counts[ & board] ,
417425 "the move-sequence count must be the un-normalized line count for {board:?}"
418426 ) ;
419427
@@ -433,7 +441,10 @@ mod tests {
433441 }
434442 }
435443 assert ! ( checked > 50 , "only {checked} boards exercised" ) ;
436- assert ! ( with_forced > 0 , "no board had any forced jump - test proves nothing" ) ;
444+ assert ! (
445+ with_forced > 0 ,
446+ "no board had any forced jump - test proves nothing"
447+ ) ;
437448 }
438449
439450 /// The opening's four first moves are symmetric images of each other, so the player really
@@ -473,8 +484,14 @@ mod tests {
473484 . expect ( "a winnable two-peg board must exist" ) ;
474485
475486 let verdicts = classify_moves ( two_pegs, & set, & counts) ;
476- let required = verdicts. iter ( ) . filter ( |( _, v) | * v == Verdict :: Required ) . count ( ) ;
477- assert_eq ! ( required, 1 , "exactly one move can finish a won two-peg board" ) ;
487+ let required = verdicts
488+ . iter ( )
489+ . filter ( |( _, v) | * v == Verdict :: Required )
490+ . count ( ) ;
491+ assert_eq ! (
492+ required, 1 ,
493+ "exactly one move can finish a won two-peg board"
494+ ) ;
478495 assert_eq ! ( forced_moves( two_pegs, & set, & counts) . len( ) , 1 ) ;
479496 }
480497}
0 commit comments