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 10
10
- Error is now a struct.
11
11
- The declarations order is more flexible.
12
12
- Way better error reporting when there is a syntax error in the macro call.
13
+ - ` Result ` generation can be disabled.
13
14
14
15
# 0.5.0
15
16
Original file line number Diff line number Diff line change @@ -17,6 +17,21 @@ macro_rules! error_chain_processed {
17
17
types {
18
18
$error_name: ident, $error_kind_name: ident, $result_name: ident;
19
19
}
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
+ }
20
35
21
36
links {
22
37
$( $link_error_path: path, $link_variant: ident $( , #[ $meta_links: meta] ) * ; ) *
@@ -204,9 +219,6 @@ macro_rules! error_chain_processed {
204
219
e. kind
205
220
}
206
221
}
207
-
208
- /// Convenient wrapper around `std::Result`.
209
- pub type $result_name<T > = :: std:: result:: Result <T , $error_name>;
210
222
} ;
211
223
}
212
224
Original file line number Diff line number Diff line change 127
127
//! Error, ErrorKind, Result;
128
128
//! }
129
129
//!
130
+ //! // Without the `Result` wrapper:
131
+ //! //
132
+ //! // types {
133
+ //! // Error, ErrorKind;
134
+ //! // }
135
+ //!
130
136
//! // Automatic conversions between this error chain and other
131
137
//! // error chains. In this case, it will e.g. generate an
132
138
//! // `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 {
389
389
}
390
390
}
391
391
}
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