#[doc(alias = "optionally_unsafe")]
macro_rules! optionally_unsafe_impl {
{$($tokens: tt)*} => {
cfg_if::cfg_if! {
if #[cfg(feature = "unsafe")] {
unsafe { $($tokens)* }
} else {
{ $($tokens)* }
}
}
};
}
pub(crate) use optionally_unsafe_impl as optionally_unsafe;
#[doc(alias = "invariant")]
macro_rules! invariant_impl {
($expr: expr) => {
cfg_if::cfg_if! {
if #[cfg(all(feature = "unsafe", ffuzzy_assume = "stable", not(test)))] {
#[allow(clippy::incompatible_msrv)]
unsafe {
core::hint::assert_unchecked($expr);
}
} else if #[cfg(all(feature = "unsafe", not(test)))] {
if !($expr) {
unsafe {
core::hint::unreachable_unchecked();
}
}
} else {
debug_assert!($expr);
}
}
};
}
pub(crate) use invariant_impl as invariant;
macro_rules! impl_error_impl {
($type: ty { $($tokens: tt)* }) => {
#[cfg(feature = "std")]
#[cfg_attr(feature = "unstable", doc(cfg(all())))]
impl std::error::Error for $type {
$($tokens)*
}
#[cfg(all(not(feature = "std"), ffuzzy_error_in_core = "stable"))]
impl core::error::Error for $type {
$($tokens)*
}
}
}
pub(crate) use impl_error_impl as impl_error;
mod tests;