From 746e3bf17463a377b6c54b291ebef9a736d6ceb7 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 25 Jan 2024 11:24:36 +0100 Subject: chore: autoformat code Use #[rustfmt:skip] to preserve aligned blocks --- src/moves.rs | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'src/moves.rs') diff --git a/src/moves.rs b/src/moves.rs index b338afe..5dc769c 100644 --- a/src/moves.rs +++ b/src/moves.rs @@ -1,6 +1,6 @@ -use std::{str::Chars, fmt::Display}; +use std::{fmt::Display, str::Chars}; -use crate::{square::Square, bitboard::BitboardFns, board::piece::Piece}; +use crate::{bitboard::BitboardFns, board::piece::Piece, square::Square}; #[derive(Debug, Clone, PartialEq, Eq, Copy)] pub enum MoveKind { @@ -27,7 +27,10 @@ impl Move { /// Tactical move is a move that changes material score pub fn is_tactical(&self) -> bool { - matches!(self.kind, MoveKind::Capture | MoveKind::EnPassant | MoveKind::Promotion(_)) + matches!( + self.kind, + MoveKind::Capture | MoveKind::EnPassant | MoveKind::Promotion(_) + ) } pub fn from_notation(mut notation: Chars) -> Self { @@ -40,27 +43,33 @@ impl Move { 'q' => Piece::Queen, 'b' => Piece::Bishop, 'n' => Piece::Knight, - _ => panic!("Illegal promotion piece: {:?}", promotion) + _ => panic!("Illegal promotion piece: {:?}", promotion), }; - return Move { source, target, kind: MoveKind::Promotion(piece) } + return Move { + source, + target, + kind: MoveKind::Promotion(piece), + }; + } + Move { + source, + target, + kind: MoveKind::Quiet, } - Move { source, target, kind: MoveKind::Quiet } } } impl Display for Move { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let promotion_postfix = match self.kind { - MoveKind::Promotion(piece) => { - match piece.without_color() { - Piece::Rook => "r", - Piece::Queen => "q", - Piece::Bishop => "b", - Piece::Knight => "n", - _ => panic!("Illegal promotion piece: {:?}", piece) - } - } - _ => "" + MoveKind::Promotion(piece) => match piece.without_color() { + Piece::Rook => "r", + Piece::Queen => "q", + Piece::Bishop => "b", + Piece::Knight => "n", + _ => panic!("Illegal promotion piece: {:?}", piece), + }, + _ => "", }; write!(f, "{}{}{}", self.source, self.target, promotion_postfix) } -- cgit v1.2.3