Skip to content

Commit

Permalink
Pass self by value for all Move functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jgilchrist committed Nov 1, 2024
1 parent acbb548 commit 459bd2d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/chess/moves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,32 +160,32 @@ impl Move {
}

#[inline]
fn data(&self) -> u16 {
fn data(self) -> u16 {
self.0.get()
}

#[inline]
pub fn src(&self) -> Square {
pub fn src(self) -> Square {
Square::from_index((self.data() & SRC_MASK) as u8)
}

#[inline]
pub fn dst(&self) -> Square {
pub fn dst(self) -> Square {
Square::from_index(((self.data() & DST_MASK) >> DST_SHIFT) as u8)
}

#[inline]
pub fn is_capture(&self) -> bool {
pub fn is_capture(self) -> bool {
(self.data() & CAPTURE_BIT_MASK) == CAPTURE_BIT_MASK
}

#[inline]
pub fn is_promotion(&self) -> bool {
pub fn is_promotion(self) -> bool {
(self.data() & PROMOTION_BIT_MASK) == PROMOTION_BIT_MASK
}

#[inline]
pub fn promotion(&self) -> Option<PromotionPieceKind> {
pub fn promotion(self) -> Option<PromotionPieceKind> {
if !self.is_promotion() {
return None;
}
Expand All @@ -202,19 +202,19 @@ impl Move {
}

#[inline]
pub fn is_quiet(&self) -> bool {
pub fn is_quiet(self) -> bool {
!self.is_promotion() && !self.is_capture()
}

#[inline]
pub fn is_en_passant(&self) -> bool {
pub fn is_en_passant(self) -> bool {
self.is_capture()
&& !self.is_promotion()
&& (self.data() & FIRST_FLAG_MASK) == FIRST_FLAG_MASK
}

#[inline]
pub fn is_castling(&self) -> bool {
pub fn is_castling(self) -> bool {
self.is_quiet() && (self.data() & FIRST_FLAG_MASK) == FIRST_FLAG_MASK
}
}
Expand Down

0 comments on commit 459bd2d

Please sign in to comment.