diff --git a/src/board/castle_rights.rs b/src/board/castle_rights.rs index b34d952..5b06544 100644 --- a/src/board/castle_rights.rs +++ b/src/board/castle_rights.rs @@ -18,6 +18,10 @@ impl CastleRights { pub const NUM_VARIANTS: usize = 4; /// Convert from a castle rights index into a [CastleRights] type. + /// + /// # Panics + /// + /// Panics if the index is out of bounds. #[inline(always)] pub fn from_index(index: usize) -> Self { assert!(index < Self::NUM_VARIANTS); diff --git a/src/board/color.rs b/src/board/color.rs index 66b21b3..17ebcb5 100644 --- a/src/board/color.rs +++ b/src/board/color.rs @@ -19,6 +19,10 @@ impl Color { } /// Convert from a color index into a [Color] type. + /// + /// # Panics + /// + /// Panics if the index is out of bounds. #[inline(always)] pub fn from_index(index: usize) -> Self { assert!(index < Self::NUM_VARIANTS); diff --git a/src/board/file.rs b/src/board/file.rs index 1475e9a..5398660 100644 --- a/src/board/file.rs +++ b/src/board/file.rs @@ -35,6 +35,10 @@ impl File { } /// Convert from a file index into a [File] type. + /// + /// # Panics + /// + /// Panics if the index is out of bounds. #[inline(always)] pub fn from_index(index: usize) -> Self { assert!(index < Self::NUM_VARIANTS); diff --git a/src/board/piece.rs b/src/board/piece.rs index 58f989a..76d9df9 100644 --- a/src/board/piece.rs +++ b/src/board/piece.rs @@ -28,6 +28,10 @@ impl Piece { } /// Convert from a piece index into a [Piece] type. + /// + /// # Panics + /// + /// Panics if the index is out of bounds. #[inline(always)] pub fn from_index(index: usize) -> Self { assert!(index < Self::NUM_VARIANTS); diff --git a/src/board/rank.rs b/src/board/rank.rs index f448df5..f716bde 100644 --- a/src/board/rank.rs +++ b/src/board/rank.rs @@ -35,6 +35,10 @@ impl Rank { } /// Convert from a rank index into a [Rank] type. + /// + /// # Panics + /// + /// Panics if the index is out of bounds. #[inline(always)] pub fn from_index(index: usize) -> Self { assert!(index < Self::NUM_VARIANTS); diff --git a/src/board/square.rs b/src/board/square.rs index 958c3c9..afbd9bf 100644 --- a/src/board/square.rs +++ b/src/board/square.rs @@ -39,6 +39,10 @@ impl Square { ]; /// Construct a [Square] from a [File] and [Rank]. + /// + /// # Panics + /// + /// Panics if the index is out of bounds. #[inline(always)] pub fn new(file: File, rank: Rank) -> Self { // SAFETY: we know the value is in-bounds