A failure-like derive macro for the std Error.
The source code mostly copied from failure-derive.
Display implementationError implementation (implementing source to return the cause of the error)Cargo.toml:
toml
[dependencies]
err-derive = "0.1"
Rust code:
```rust
extern crate err_derive;
use std::io;
/// MyError::source will return a reference to the io_error field
struct MyError { #[error(cause)] io_error: io::Error, }
/// MyEnumError::source will return a reference only if it is Variant2,
/// otherwise it will return None.
enum MyEnumError { #[error(display = "An error occurred.")] Variant1, #[error(display = "A different error occurred.")] Variant2(#[error(cause)] io::Error), } ```
This project is dual-licensed under Apache-2.0 / MIT. You're free to choose one of both licenses. Every contribution made to this project is assumed to be licensed according to these terms.
See LICENSE, LICENSE-MIT and LICENSE-APACHE for more information.