#error #macro #enums #auto #misc #error-enum #from-error

err

A few macros & misc that make using rust's Error infrastructure more convenient

8 releases

Uses old Rust 2015

0.0.8 Apr 3, 2015
0.0.7 Mar 4, 2015
0.0.4 Feb 26, 2015

#10 in #misc

40 downloads per month
Used in dev

MIT license

5KB
133 lines

err

A collection of macros for working with FromError, the most useful of which is error_enum!

#[macro_use]
extern crate err;

error_enum! {
	enum MyError {
		bare SomethingCustom(&'static str),
		auto Io(std::io::Error)
	}

	enum MyOtherError {
		auto MyError(MyError)
	}
}

// An all the elements marked `auto` have auto-generated FromError
// implimentations created with the assumption that they are simple wrappers
// around a type.

Limitations

  • No-arg enum elements are not supported
  • Trailing commas on the last enum element are not supported

No runtime deps