Implement Index<T>, IndexMut<T> for Castle, PieceType and Color enums, use swap_remove instead of remove on sort_moves

This commit is contained in:
stefiosif
2024-12-01 10:52:38 +02:00
parent 316f40e6e5
commit f7604b27a5
4 changed files with 62 additions and 35 deletions

View File

@@ -5,7 +5,7 @@ use crate::{
pub fn sort_moves(mut moves: Vec<Move>, mailbox: &Mailbox, tt_move: Option<Move>) -> Vec<Move> {
if let Some(tt_move) = tt_move {
if let Some(tt_move_index) = moves.iter().position(|&mv| mv == tt_move) {
moves.remove(tt_move_index);
moves.swap_remove(tt_move_index);
moves.insert(0, tt_move);
return moves;
}