Skip to content

Commit

Permalink
use let else
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Sep 30, 2023
1 parent 08d9d80 commit 40b5c0d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/bitboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ impl Bitboard {
/// Discards the last square.
#[inline]
pub fn discard_last(&mut self) {
*self = self.without_last()
*self = self.without_last();
}

/// Returns `self` without the last square.
Expand Down
5 changes: 2 additions & 3 deletions src/san.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,8 @@ impl San {
pub fn find_move<'a>(&self, moves: &'a MoveList) -> Result<&'a Move, SanError> {
let mut filtered = moves.iter().filter(|m| self.matches(m));

let m = match filtered.next() {
Some(m) => m,
None => return Err(SanError::IllegalSan),
let Some(m) = filtered.next() else {
return Err(SanError::IllegalSan);
};

if filtered.next().is_some() {
Expand Down
5 changes: 2 additions & 3 deletions src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,8 @@ impl From<EnPassant> for Square {

impl EnPassant {
pub fn from_setup(setup: &Setup) -> Result<Option<EnPassant>, ()> {
let ep_square = match setup.ep_square {
Some(ep_square) => ep_square,
None => return Ok(None),
let Some(ep_square) = setup.ep_square else {
return Ok(None);
};

if ep_square.rank() != setup.turn.relative_rank(Rank::Sixth) {
Expand Down

0 comments on commit 40b5c0d

Please sign in to comment.