From 353271f427ed18c752f9238db72577b00117cb4d Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 1 Apr 2024 23:11:43 +0100 Subject: [PATCH] Simplify 'FromFen' for 'ChessBoard' --- src/fen.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/fen.rs b/src/fen.rs index a7a6825..90f6dd1 100644 --- a/src/fen.rs +++ b/src/fen.rs @@ -139,20 +139,19 @@ impl FromFen for ChessBoard { builder.with_castle_rights(castle_rights[color.index()], color); } - let side = Color::from_fen(side_to_move)?; - builder.with_current_player(side); + builder.with_current_player(FromFen::from_fen(side_to_move)?); - if let Some(square) = Option::::from_fen(en_passant_square)? { + if let Some(square) = FromFen::from_fen(en_passant_square)? { builder.with_en_passant(square); }; let half_move_clock = half_move_clock - .parse::() + .parse::<_>() .map_err(|_| FenError::InvalidFen)?; builder.with_half_move_clock(half_move_clock); let full_move_counter = full_move_counter - .parse::() + .parse::<_>() .map_err(|_| FenError::InvalidFen)?; builder.with_turn_count(full_move_counter); @@ -173,7 +172,7 @@ impl FromFen for ChessBoard { file += digit.to_digit(10).unwrap() as usize; continue; } - _ => Piece::from_fen(&c.to_string())?, + _ => FromFen::from_fen(&c.to_string())?, }; // Only need to worry about underflow since those are `usize` values.