@@ -106,11 +106,9 @@ impl Move {
106106 matches ! ( self . kind( ) , MoveKind :: DoublePush )
107107 }
108108
109- pub const fn promotion_piece ( self ) -> Option < PieceType > {
110- if self . is_promotion ( ) {
111- return Some ( PieceType :: new ( ( ( self . kind ( ) as usize ) & 3 ) + PieceType :: Knight as usize ) ) ;
112- }
113- None
109+ pub const fn promo_piece_type ( self ) -> PieceType {
110+ debug_assert ! ( self . is_promotion( ) ) ;
111+ PieceType :: new ( ( ( self . kind ( ) as usize ) & 3 ) + PieceType :: Knight as usize )
114112 }
115113
116114 pub fn to_uci ( self , board : & Board ) -> String {
@@ -124,11 +122,11 @@ impl Move {
124122 let mut output = format ! ( "{}{}" , self . from( ) , self . to( ) ) ;
125123
126124 if self . is_promotion ( ) {
127- match self . promotion_piece ( ) {
128- Some ( PieceType :: Knight ) => output. push ( 'n' ) ,
129- Some ( PieceType :: Bishop ) => output. push ( 'b' ) ,
130- Some ( PieceType :: Rook ) => output. push ( 'r' ) ,
131- Some ( PieceType :: Queen ) => output. push ( 'q' ) ,
125+ match self . promo_piece_type ( ) {
126+ PieceType :: Knight => output. push ( 'n' ) ,
127+ PieceType :: Bishop => output. push ( 'b' ) ,
128+ PieceType :: Rook => output. push ( 'r' ) ,
129+ PieceType :: Queen => output. push ( 'q' ) ,
132130 _ => ( ) ,
133131 }
134132 }
0 commit comments