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

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

View file

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