diff --git a/src/board/castle_rights.rs b/src/board/castle_rights.rs index 5bd9d91..81cb5a6 100644 --- a/src/board/castle_rights.rs +++ b/src/board/castle_rights.rs @@ -17,6 +17,18 @@ impl CastleRights { /// The number of [CastleRights] variants. pub const NUM_VARIANTS: usize = 4; + const ALL: [Self; Self::NUM_VARIANTS] = [ + Self::NoSide, + Self::KingSide, + Self::QueenSide, + Self::BothSides, + ]; + + /// Iterate over all castle-rights variants. + pub fn iter() -> impl Iterator { + Self::ALL.iter().cloned() + } + /// Convert from a castle rights index into a [CastleRights] type. /// /// # Panics