From 063d19f9d2f89cb73e685adcb9473f986133c22a Mon Sep 17 00:00:00 2001 From: Igor Polyakov Date: Sat, 4 May 2019 21:55:49 -0700 Subject: [PATCH] Made the simple example even simpler since the error as cause example already shows chaining --- examples/simple.rs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/examples/simple.rs b/examples/simple.rs index fc39601..014f030 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -1,22 +1,10 @@ -#[macro_use] -extern crate failure; - use failure::Fail; #[derive(Debug, Fail)] -#[fail(display = "my error")] +#[fail(display = "Hello World")] struct MyError; -#[derive(Debug, Fail)] -#[fail(display = "my wrapping error")] -struct WrappingError(#[fail(cause)] MyError); - -fn bad_function() -> Result<(), WrappingError> { - Err(WrappingError(MyError)) -} - fn main() { - for cause in Fail::iter_chain(&bad_function().unwrap_err()) { - println!("{}: {}", cause.name().unwrap_or("Error"), cause); - } + let err: Result<(), MyError> = Err(MyError); + println!("{}", err.unwrap_err()); }