#[macro_use] mod logging_def; #[cfg(feature = "rng")] pub mod rand; #[cfg(not(feature = "rng"))] pub mod rand {} pub mod chksum; pub mod file; pub mod index; pub mod logging; pub mod n_iter; pub mod result; pub mod slicing; pub mod vec; pub mod ext { pub trait InspectCell { fn inspect(&self, f: impl Fn(&T) -> R) -> R; } impl InspectCell for std::cell::Cell { fn inspect(&self, f: impl Fn(&T) -> R) -> R { let s = unsafe { &*self.as_ptr() }; f(s) } } pub trait UnwrapValid { fn valid(self) -> T; } impl UnwrapValid for Option { fn valid(self) -> T { #[cfg(debug_assertions)] { self.expect("E| Not valid: None") } #[cfg(not(debug_assertions))] { unsafe { self.unwrap_unchecked() } } } } impl UnwrapValid for Result { fn valid(self) -> T { #[cfg(debug_assertions)] { self.expect("E| Not valid: Err") } #[cfg(not(debug_assertions))] { unsafe { self.unwrap_unchecked() } } } } pub trait OrAssignment { fn or_def(self, filter: bool) -> Self; fn or_val(self, filter: bool, val: Self) -> Self; } impl OrAssignment for T { fn or_def(self, filter: bool) -> Self { if filter { self } else { Self::default() } } fn or_val(self, filter: bool, v: Self) -> Self { if filter { self } else { v } } } }