Add 'Panics' section to 'from_index' methods
This commit is contained in:
parent
7d9c5edb99
commit
753f1590d1
|
@ -18,6 +18,10 @@ impl CastleRights {
|
||||||
pub const NUM_VARIANTS: usize = 4;
|
pub const NUM_VARIANTS: usize = 4;
|
||||||
|
|
||||||
/// Convert from a castle rights index into a [CastleRights] type.
|
/// Convert from a castle rights index into a [CastleRights] type.
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// Panics if the index is out of bounds.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn from_index(index: usize) -> Self {
|
pub fn from_index(index: usize) -> Self {
|
||||||
assert!(index < Self::NUM_VARIANTS);
|
assert!(index < Self::NUM_VARIANTS);
|
||||||
|
|
|
@ -19,6 +19,10 @@ impl Color {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert from a color index into a [Color] type.
|
/// Convert from a color index into a [Color] type.
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// Panics if the index is out of bounds.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn from_index(index: usize) -> Self {
|
pub fn from_index(index: usize) -> Self {
|
||||||
assert!(index < Self::NUM_VARIANTS);
|
assert!(index < Self::NUM_VARIANTS);
|
||||||
|
|
|
@ -35,6 +35,10 @@ impl File {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert from a file index into a [File] type.
|
/// Convert from a file index into a [File] type.
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// Panics if the index is out of bounds.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn from_index(index: usize) -> Self {
|
pub fn from_index(index: usize) -> Self {
|
||||||
assert!(index < Self::NUM_VARIANTS);
|
assert!(index < Self::NUM_VARIANTS);
|
||||||
|
|
|
@ -28,6 +28,10 @@ impl Piece {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert from a piece index into a [Piece] type.
|
/// Convert from a piece index into a [Piece] type.
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// Panics if the index is out of bounds.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn from_index(index: usize) -> Self {
|
pub fn from_index(index: usize) -> Self {
|
||||||
assert!(index < Self::NUM_VARIANTS);
|
assert!(index < Self::NUM_VARIANTS);
|
||||||
|
|
|
@ -35,6 +35,10 @@ impl Rank {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert from a rank index into a [Rank] type.
|
/// Convert from a rank index into a [Rank] type.
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// Panics if the index is out of bounds.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn from_index(index: usize) -> Self {
|
pub fn from_index(index: usize) -> Self {
|
||||||
assert!(index < Self::NUM_VARIANTS);
|
assert!(index < Self::NUM_VARIANTS);
|
||||||
|
|
|
@ -39,6 +39,10 @@ impl Square {
|
||||||
];
|
];
|
||||||
|
|
||||||
/// Construct a [Square] from a [File] and [Rank].
|
/// Construct a [Square] from a [File] and [Rank].
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// Panics if the index is out of bounds.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn new(file: File, rank: Rank) -> Self {
|
pub fn new(file: File, rank: Rank) -> Self {
|
||||||
// SAFETY: we know the value is in-bounds
|
// SAFETY: we know the value is in-bounds
|
||||||
|
|
Loading…
Reference in a new issue