pub trait ErrorBacktrace {
// Required method
fn is_error(&self) -> bool;
// Provided methods
fn trace(self) -> Self
where Self: Sized { ... }
fn backtrace(self) -> Self
where Self: Sized { ... }
fn handle_error(self) -> Self
where Self: Sized { ... }
}
fn error_source() -> Result<(), ()> {
Err(()).trace()
}
fn main() -> Result<(), ()> {
maybe_error().backtrace()?;
Ok(())
}
fn maybe_error() -> Result<(), ()> {
error_source()?;
match error_source().handle_error() {
Ok(x) => x,
Err(e) => e,
};
Ok(())
}