Make more readability refactorings

This commit is contained in:
stefiosif
2024-08-28 23:27:40 +03:00
parent 46cf0f0d1f
commit e61d247411
6 changed files with 42 additions and 60 deletions

View File

@@ -12,7 +12,7 @@ pub fn from_fen(fen: &str) -> Result<Game, FenError> {
let castling_ability = castling_ability(fen_parts[2])?;
let en_passant_target_square = en_passant_target_square(fen_parts[3])?;
let en_passant_square = en_passant_square(fen_parts[3])?;
let halfmove_clock = halfmove_clock(fen_parts[4])?;
@@ -21,7 +21,7 @@ pub fn from_fen(fen: &str) -> Result<Game, FenError> {
board.set_state(State::load_state(
side_to_move,
castling_ability,
en_passant_target_square,
en_passant_square,
halfmove_clock,
fullmove_counter,
));
@@ -123,7 +123,7 @@ fn castling_ability(castling: &str) -> Result<[Castle; 2], FenError> {
use std::collections::HashMap;
fn en_passant_target_square(square: &str) -> Result<Option<usize>, FenError> {
fn en_passant_square(square: &str) -> Result<Option<usize>, FenError> {
let mut sqr = square.chars();
let mut files: HashMap<char, usize> = HashMap::new();