Add '# Safety' section to 'unsafe fn' doc

This commit is contained in:
Bruno BELANYI 2022-07-22 18:49:16 +02:00
parent fc26b264e4
commit d5a8da8263
6 changed files with 24 additions and 0 deletions

View file

@ -36,6 +36,10 @@ impl Piece {
}
/// Convert from a piece index into a [Piece] type, no bounds checking.
///
/// # Safety
///
/// Should only be called with values that can be output by [Piece::index()].
#[inline(always)]
pub unsafe fn from_index_unchecked(index: usize) -> Self {
std::mem::transmute(index as u8)