Skip to content

Commit

Permalink
use is_some_and
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Jan 4, 2025
1 parent 1653df1 commit fbc087b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/fen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ fn append_castling<W: AppendAscii>(

for rook in (castling_rights & color.backrank()).into_iter().rev() {
f.append_ascii(
if Some(rook) == candidates.first() && king.map_or(false, |k| rook < k) {
if Some(rook) == candidates.first() && king.is_some_and(|k| rook < k) {
color.fold_wb('Q', 'q')
} else if Some(rook) == candidates.last() && king.map_or(false, |k| k < rook) {
} else if Some(rook) == candidates.last() && king.is_some_and(|k| k < rook) {
color.fold_wb('K', 'k')
} else {
let file = rook.file();
Expand Down
2 changes: 1 addition & 1 deletion src/position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ pub trait Position {
/// Generates legal castling moves.
fn castling_moves(&self, side: CastlingSide) -> MoveList {
let mut moves = self.legal_moves();
moves.retain(|m| m.castling_side().map_or(false, |s| side == s));
moves.retain(|m| m.castling_side().is_some_and(|s| side == s));
moves
}

Expand Down
2 changes: 1 addition & 1 deletion src/san.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ impl San {
}
_ => false,
},
San::Castle(side) => m.castling_side().map_or(false, |s| side == s),
San::Castle(side) => m.castling_side().is_some_and(|s| side == s),
San::Put { role, to } => match *m {
Move::Put { role: r, to: t } => r == role && to == t,
_ => false,
Expand Down

0 comments on commit fbc087b

Please sign in to comment.