This repository was archived by the owner on Aug 16, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +42
-3
lines changed Expand file tree Collapse file tree 4 files changed +42
-3
lines changed Original file line number Diff line number Diff line change 1010- Error is now a struct.
1111- The declarations order is more flexible.
1212- Way better error reporting when there is a syntax error in the macro call.
13+ - ` Result ` generation can be disabled.
1314
1415# 0.5.0
1516
Original file line number Diff line number Diff line change @@ -17,6 +17,21 @@ macro_rules! error_chain_processed {
1717 types {
1818 $error_name: ident, $error_kind_name: ident, $result_name: ident;
1919 }
20+ $( $rest: tt ) *
21+ ) => {
22+ error_chain_processed! {
23+ types {
24+ $error_name, $error_kind_name;
25+ }
26+ $( $rest ) *
27+ }
28+ /// Convenient wrapper around `std::Result`.
29+ pub type $result_name<T > = :: std:: result:: Result <T , $error_name>;
30+ } ;
31+ (
32+ types {
33+ $error_name: ident, $error_kind_name: ident;
34+ }
2035
2136 links {
2237 $( $link_error_path: path, $link_variant: ident $( , #[ $meta_links: meta] ) * ; ) *
@@ -204,9 +219,6 @@ macro_rules! error_chain_processed {
204219 e. kind
205220 }
206221 }
207-
208- /// Convenient wrapper around `std::Result`.
209- pub type $result_name<T > = :: std:: result:: Result <T , $error_name>;
210222 } ;
211223}
212224
Original file line number Diff line number Diff line change 127127//! Error, ErrorKind, Result;
128128//! }
129129//!
130+ //! // Without the `Result` wrapper:
131+ //! //
132+ //! // types {
133+ //! // Error, ErrorKind;
134+ //! // }
135+ //!
130136//! // Automatic conversions between this error chain and other
131137//! // error chains. In this case, it will e.g. generate an
132138//! // `ErrorKind` variant called `Dist` which in turn contains
Original file line number Diff line number Diff line change @@ -389,3 +389,23 @@ mod attributes_test {
389389 }
390390 }
391391}
392+
393+ #[ test]
394+ fn with_result ( ) {
395+ error_chain ! {
396+ types {
397+ Error , ErrorKind , Result ;
398+ }
399+ }
400+ let _: Result < ( ) > = Ok ( ( ) ) ;
401+ }
402+
403+ #[ test]
404+ fn without_result ( ) {
405+ error_chain ! {
406+ types {
407+ Error , ErrorKind ;
408+ }
409+ }
410+ let _: Result < ( ) , ( ) > = Ok ( ( ) ) ;
411+ }
You can’t perform that action at this time.
0 commit comments