#![cfg_attr(not(feature = "power-of-two"), allow(unused_macros))]
#![doc(hidden)]
macro_rules! safe_assert {
($cond:expr $(,)?) => {
#[cfg(feature = "safe")]
assert!($cond);
};
}
#[cfg(not(feature = "safe"))]
macro_rules! index_unchecked {
($x:ident[$i:expr]) => {
*$x.get_unchecked($i)
};
}
#[cfg(not(feature = "safe"))]
macro_rules! index_unchecked_mut {
($x:ident[$i:expr]) => {
*$x.get_unchecked_mut($i)
};
($x:ident[$i:expr] = $y:ident[$j:expr]) => {
*$x.get_unchecked_mut($i) = *$y.get_unchecked($j)
};
}
#[cfg(not(feature = "safe"))]
macro_rules! slice_fill_unchecked {
($slc:expr, $value:expr) => {
let len = $slc.len();
core::ptr::write_bytes($slc.as_mut_ptr(), $value, len)
};
}
#[cfg(not(feature = "safe"))]
macro_rules! copy_nonoverlapping_unchecked {
($dst:expr, $src:expr, $srclen:expr) => {
core::ptr::copy_nonoverlapping($src, $dst.as_mut_ptr(), $srclen)
};
}
#[cfg(feature = "safe")]
macro_rules! index_unchecked {
($x:ident[$i:expr]) => {
$x[$i]
};
}
#[cfg(feature = "safe")]
macro_rules! index_unchecked_mut {
($x:ident[$i:expr]) => {
$x[$i]
};
($x:ident[$i:expr] = $y:ident[$j:expr]) => {
$x[$i] = $y[$j]
};
}
#[cfg(feature = "safe")]
macro_rules! slice_fill_unchecked {
($slc:expr, $value:expr) => {
$slc.fill($value)
};
}
#[cfg(feature = "safe")]
macro_rules! copy_nonoverlapping_unchecked {
($dst:expr, $src:expr, $srclen:expr) => {
let slc = unsafe { core::slice::from_raw_parts($src, $srclen) };
$dst.copy_from_slice(slc)
};
}