Skip to content

Commit

Permalink
Make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
walkie committed Mar 31, 2024
1 parent a56087a commit e19f63b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions t4t/src/moves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ pub struct PossibleMoves<'a, M> {

impl<'a, M: Move> PossibleMoves<'a, M> {
/// Construct a new possible move iterator from a cloneable iterator of moves.
pub fn from_iter(iterator: impl Clone + Iterator<Item = M> + 'a) -> Self {
pub fn new(iterator: impl Clone + Iterator<Item = M> + 'a) -> Self {
PossibleMoves {
iterator: Box::new(iterator),
}
}

/// Construct a new possible move iterator from a vector of moves.
pub fn from_vec(moves: Vec<M>) -> Self {
PossibleMoves::from_iter(moves.into_iter())
PossibleMoves::new(moves.into_iter())
}
}

Expand Down
12 changes: 6 additions & 6 deletions t4t/src/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ pub trait Record<M: Move, const P: usize> {
fn played_moves_by_chance(&self) -> PlayedMoves<M> {
let move_iter = self
.plies()
.filter(move |ply| ply.player == None)
.filter(move |ply| ply.player.is_none())
.map(|ply| ply.the_move);
PlayedMoves::from_iter(move_iter)
PlayedMoves::new(move_iter)
}

/// An iterator over all moves by a particular player.
Expand All @@ -38,7 +38,7 @@ pub trait Record<M: Move, const P: usize> {
.plies()
.filter(move |ply| ply.player == Some(player))
.map(|ply| ply.the_move);
PlayedMoves::from_iter(move_iter)
PlayedMoves::new(move_iter)
}

/// Iterators over the moves by each player.
Expand All @@ -52,7 +52,7 @@ pub trait Record<M: Move, const P: usize> {
/// This iterator is double-ended, so it can be traversed forward (starting from the beginning of
/// the game) or backward (starting from the most recent move).
pub struct PlayedMoves<'a, M> {
iterator: Box<dyn DoubleEndedIterator<Item=M> + 'a>,
iterator: Box<dyn DoubleEndedIterator<Item = M> + 'a>,
}

impl<'a, M: Move> PlayedMoves<'a, M> {
Expand All @@ -69,15 +69,15 @@ impl<'a, M: Move> PlayedMoves<'a, M> {
}

/// Construct a new played move iterator from a double-ended iterator of moves.
pub fn from_iter(iterator: impl DoubleEndedIterator<Item=M> + 'a) -> Self {
pub fn new(iterator: impl DoubleEndedIterator<Item = M> + 'a) -> Self {
PlayedMoves {
iterator: Box::new(iterator),
}
}

/// Construct a new played move iterator from a vector of moves.
pub fn from_vec(moves: Vec<M>) -> Self {
PlayedMoves::from_iter(moves.into_iter())
PlayedMoves::new(moves.into_iter())
}
}

Expand Down

0 comments on commit e19f63b

Please sign in to comment.