From 3b1735da798f948e1b3a861597db6c6b0e401db8 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sun, 31 Mar 2024 12:08:34 +0100 Subject: [PATCH] Add 'BitboardIterator::new' --- src/board/bitboard/iterator.rs | 12 ++++++++++-- src/board/bitboard/mod.rs | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/board/bitboard/iterator.rs b/src/board/bitboard/iterator.rs index fcd644c..7c01a9a 100644 --- a/src/board/bitboard/iterator.rs +++ b/src/board/bitboard/iterator.rs @@ -1,6 +1,14 @@ /// An [Iterator](std::iter::Iterator) of [Square](crate::board::Square) contained in a -/// [Bitboard](crate::board::Bitboard). -pub struct BitboardIterator(pub(crate) u64); +/// [Bitboard]. +use crate::board::Bitboard; + +pub struct BitboardIterator(u64); + +impl BitboardIterator { + pub fn new(board: Bitboard) -> Self { + Self(board.0) + } +} impl Iterator for BitboardIterator { type Item = crate::board::Square; diff --git a/src/board/bitboard/mod.rs b/src/board/bitboard/mod.rs index bccbbfa..9ef0348 100644 --- a/src/board/bitboard/mod.rs +++ b/src/board/bitboard/mod.rs @@ -91,7 +91,7 @@ impl IntoIterator for Bitboard { type Item = Square; fn into_iter(self) -> Self::IntoIter { - BitboardIterator(self.0) + BitboardIterator::new(self) } }