One-liner to compute if a chess game is a draw by repetition. I love this language.
/// This function will return true if the same
/// position occurs 3 times, at any point in the game.
pub fn is_draw_by_repetition(&self) -> bool {
self.history
.iter()
.rev()
.step_by(2)
.skip(1)
.filter(|pos| pos.masks() == self.last.position().masks())
.count()
> 1
}