wrap unimplemented ser/de branches with internal macro

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-11-01 22:43:26 +00:00
parent ba1c134689
commit 8742437036
4 changed files with 66 additions and 41 deletions

View file

@ -1,6 +1,29 @@
use conduit::{err, Result};
use rocksdb::{Direction, IteratorMode};
//#[cfg(debug_assertions)]
macro_rules! unhandled {
($msg:literal) => {
unimplemented!($msg)
};
}
// activate when stable; we're not ready for this yet
#[cfg(disable)] // #[cfg(not(debug_assertions))]
macro_rules! unhandled {
($msg:literal) => {
// SAFETY: Eliminates branches for serializing and deserializing types never
// encountered in the codebase. This can promote optimization and reduce
// codegen. The developer must verify for every invoking callsite that the
// unhandled type is in no way involved and could not possibly be encountered.
unsafe {
std::hint::unreachable_unchecked();
}
};
}
pub(crate) use unhandled;
#[inline]
pub(crate) fn _into_direction(mode: &IteratorMode<'_>) -> Direction {
use Direction::{Forward, Reverse};