The panic message from Result::expect
is not really suitable for presenting to a user as the Debug
impl will usually lead to a bunch of nested structiness. Would it make sense to add an equivalent that uses Display
instead? It would look like this:
impl<T, E: fmt::Display> Result<T, E> {
pub fn expect_pretty(self, msg: &str) -> T {
match self {
Ok(t) => t,
Err(e) => panic!("{}: {}", msg, e),
}
}
}