#![deny(missing_docs)]
#![forbid(unsafe_code)]
#![no_std]
use core::fmt::Debug;
pub trait UnwrapTodo {
type Target;
fn todo(self) -> Self::Target;
}
impl<T> UnwrapTodo for Option<T> {
type Target = T;
#[inline]
#[track_caller]
fn todo(self) -> Self::Target {
match self {
Some(t) => t,
None => unwrap_none(),
}
}
}
#[cold]
#[inline(never)]
#[track_caller]
fn unwrap_none() -> ! {
panic!("None handling not yet implemented")
}
impl<T, E> UnwrapTodo for Result<T, E>
where
E: Debug,
{
type Target = T;
#[inline]
#[track_caller]
fn todo(self) -> Self::Target {
match self {
Ok(t) => t,
Err(e) => unwrap_err(&e),
}
}
}
#[cold]
#[inline(never)]
#[track_caller]
fn unwrap_err(e: &dyn Debug) -> ! {
panic!("Err handling not yet implemented: {e:?}")
}