| Crates.io | autoerror |
| lib.rs | autoerror |
| version | 1.0.0 |
| created_at | 2021-04-23 07:24:25.963058+00 |
| updated_at | 2021-04-23 07:24:25.963058+00 |
| description | Automatically generate error handling traits. |
| homepage | |
| repository | https://github.com/tweedegolf/autoerror |
| max_upload_size | |
| id | 388477 |
| size | 16,675 |
Derive basic error type infrastruture for enum types.
Supports unnamed and unit enum variants, and uses the type definition
to derive std::fmt::Display and std::error:Error for the error type,
as well as std::from::From<T> for any unnamed variant with one parameter
inferred to be an error type (currently determined by whether it's type
name is Error).
Default behaviour can be overridden with the auto_error attribute
From derivation and source returning work only for variants with a single field.
#[derive(AutoError)]
use autoerror::AutoError;
enum Error {
#[auto_error(format_str="Document not found")]
NotFound,
IO(std::io::Error),
#[auto_error(make_from=true)]
Other(String),
}