Rename Square::from_index → from_index_unchecked
This commit is contained in:
parent
c290f00b9e
commit
ee51a13870
2 changed files with 14 additions and 8 deletions
|
@ -220,9 +220,10 @@ coordinate_enum!(Square, [
|
|||
impl Square {
|
||||
/// # Safety
|
||||
///
|
||||
/// This function does not do any bounds checking on the input.
|
||||
/// This function does not do any bounds checking on the input. In debug
|
||||
/// builds, this function will assert that the argument is in bounds.
|
||||
#[must_use]
|
||||
pub unsafe fn from_index(x: u8) -> Square {
|
||||
pub unsafe fn from_index_unchecked(x: u8) -> Square {
|
||||
debug_assert!((x as usize) < Self::NUM);
|
||||
Self::try_from(x).unwrap_unchecked()
|
||||
}
|
||||
|
@ -232,7 +233,7 @@ impl Square {
|
|||
pub fn from_file_rank(file: File, rank: Rank) -> Square {
|
||||
let file_int: u8 = file.into();
|
||||
let rank_int: u8 = rank.into();
|
||||
unsafe { Self::from_index(rank_int << 3 | file_int) }
|
||||
unsafe { Self::from_index_unchecked(rank_int << 3 | file_int) }
|
||||
}
|
||||
|
||||
pub fn from_algebraic_str(s: &str) -> Result<Square, ParseSquareError> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue