1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
pub struct PanicError; use std::fmt; impl<E> From<E> for PanicError where E: fmt::Debug, { fn from(e: E) -> Self { panic!("{:?}", e) } } pub fn unwrap<T>(r: Result<T, PanicError>) -> T { if let Ok(t) = r { t } else { unreachable!(); } }