1
0
Fork 0

update docs

This commit is contained in:
Paul-Nicolas Madelaine 2025-11-18 06:49:33 +01:00
parent 671ff331d3
commit b45952b6b7
5 changed files with 47 additions and 43 deletions

View file

@ -123,6 +123,9 @@ impl File {
}
}
/// ## Safety
///
/// The caller must ensure that `index < 8`.
#[inline]
pub const unsafe fn new_unchecked(index: u8) -> Self {
debug_assert!(index < 8);
@ -135,9 +138,9 @@ impl File {
}
#[inline]
pub const fn from_ascii(c: u8) -> Option<Self> {
if c <= b'h' {
match c.checked_sub(b'a') {
pub const fn from_ascii(file: u8) -> Option<Self> {
if file <= b'h' {
match file.checked_sub(b'a') {
Some(i) => Some(unsafe { Self::new_unchecked(i) }),
None => None,
}
@ -213,6 +216,9 @@ impl Rank {
}
}
/// ## Safety
///
/// The caller must ensure that `index < 8`.
#[inline]
pub const unsafe fn new_unchecked(index: u8) -> Self {
debug_assert!(index < 8);
@ -225,9 +231,9 @@ impl Rank {
}
#[inline]
pub const fn from_ascii(c: u8) -> Option<Self> {
if c <= b'8' {
match c.checked_sub(b'1') {
pub const fn from_ascii(rank: u8) -> Option<Self> {
if rank <= b'8' {
match rank.checked_sub(b'1') {
Some(i) => Some(unsafe { Self::new_unchecked(i) }),
None => None,
}