use std::fmt::Debug;
pub trait DebugUnwrap: Sized {
type Output;
#[cfg(any(debug_assertions, feature="deprecate"))]
#[cfg_attr(
all(not(debug_assertions), feature = "deprecate"),
deprecated = "Debug unwrap must not be used in release mode"
)]
fn debug_unwrap(self) -> Self::Output;
#[cfg(all(any(debug_assertions, feature="deprecate"), feature="out"))]
#[cfg_attr(
all(not(debug_assertions), feature = "deprecate"),
deprecated = "Debug unwrap must not be used in release mode"
)]
fn out(self) -> Self::Output {
#[allow(deprecated)]
self.debug_unwrap()
}
#[cfg(all(any(debug_assertions, feature="deprecate"), feature="o"))]
#[cfg_attr(
all(not(debug_assertions), feature = "deprecate"),
deprecated = "Debug unwrap must not be used in release mode"
)]
fn o(self) -> Self::Output {
#[allow(deprecated)]
self.debug_unwrap()
}
#[cfg(all(any(debug_assertions, feature="deprecate"), feature="peel"))]
#[cfg_attr(
all(not(debug_assertions), feature = "deprecate"),
deprecated = "Debug unwrap must not be used in release mode"
)]
fn peel(self) -> Self::Output {
#[allow(deprecated)]
self.debug_unwrap()
}
}
impl<T: Sized> DebugUnwrap for Option<T> {
type Output = T;
#[cfg(any(debug_assertions, feature="deprecate"))]
fn debug_unwrap(self) -> T {
self.unwrap()
}
}
impl<T: Sized, E: Debug> DebugUnwrap for Result<T, E> {
type Output = T;
#[cfg(any(debug_assertions, feature="deprecate"))]
fn debug_unwrap(self) -> T {
self.unwrap()
}
}