Skip to content

Commit

Permalink
Remove Clippy warnings introduced with Rust 1.82
Browse files Browse the repository at this point in the history
  • Loading branch information
carsten-wenderdel committed Nov 3, 2024
1 parent 6772abe commit 274e6df
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions crates/engine/src/evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ pub trait Evaluator {

/// [BatchEvaluator] is a subtrait of [Evaluator]. The function [Evaluator::eval_batch] is
/// implemented by default. This trait is meant for evaluating all legal moves at once.
///
/// An example is [crate::onnx::OnnxEvaluator], where feeding several positions at once to the
/// neural net is more performant than evaluating them one by one.
///
Expand Down
4 changes: 2 additions & 2 deletions crates/engine/src/position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ impl Position {

#[inline]
fn can_move_internally(&self, from: usize, die: usize) -> bool {
return if self.pips[from] < 1 {
if self.pips[from] < 1 {
// no checker to move
false
} else if from > die {
Expand All @@ -321,7 +321,7 @@ impl Position {
// from < die, bear off
let checker_on_bigger_pip = self.pips[from + 1..X_BAR].iter().any(|x| x > &0);
!checker_on_bigger_pip
};
}
}

/// Works for all of moves, including those from the bar
Expand Down
3 changes: 2 additions & 1 deletion crates/engine/src/position/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use base64::engine::general_purpose;
use base64::Engine;
use std::collections::HashMap;

/// Simple way to create positions for testing
/// Simple way to create positions for testing.
///
/// The starting position would be:
/// pos!(x 24:2, 13:5, 8:3, 6:5; o 19:5, 17:3, 12:5, 1:2)
/// The order is not important, so this is equivalent:
Expand Down
4 changes: 2 additions & 2 deletions crates/engine/src/position/double_moves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl Position {
return max_return_value;
}
// bear off moves
return match position.pips.iter().rposition(|&p| p > 0) {
match position.pips.iter().rposition(|&p| p > 0) {
None => number_of_checkers,
Some(biggest_pip) => {
let bearoff_checkers: u32 = if biggest_pip > 6 {
Expand All @@ -136,7 +136,7 @@ impl Position {
number_of_checkers += bearoff_checkers;
min(number_of_checkers, max_return_value)
}
};
}
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/logic/src/bg_move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub struct BgMove {
#[derive(Debug, PartialEq)]
#[cfg_attr(feature = "web", derive(Serialize, ToSchema))]
/// Single movement of one checker. We always move from bigger pips to smaller pips.
///
/// If the same checker is moved more than once, multiple `MoveDetail`s are given.
/// Therefore: `from > to` and `from - to <= 6`.
pub struct MoveDetail {
Expand Down
2 changes: 2 additions & 0 deletions crates/web/src/web_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ pub struct MoveInfo {
// This is similar to evaluator::Probabilities. But while the former serves
// as a model for calculations, this is more like a view model for the web API.
// While in evaluator::Probabilities all 6 numbers add up to 1.0, this is different.
/// Chances for winning/losing normal/gammon/backgammon.
///
/// `win` includes the chances to win gammon or BG.
/// `winG` includes the chances to win BG and `loseG` includes the chance to lose BG.
/// This way we use the same format as earlier engines like GnuBG have done.
Expand Down

0 comments on commit 274e6df

Please sign in to comment.