@@ -40,7 +40,7 @@ macro_rules! error_chain_processed {
40
40
}
41
41
42
42
derive {
43
- $( $trait : ident) ,*
43
+ $( $bound : ident) ,*
44
44
}
45
45
46
46
links {
@@ -58,6 +58,10 @@ macro_rules! error_chain_processed {
58
58
}
59
59
60
60
) => {
61
+ use :: std:: fmt:: Debug ;
62
+ use :: std:: error:: Error as StdError ;
63
+ create_super_trait!( Trait : Debug , StdError , Send $( , $bound) * ) ;
64
+
61
65
/// The Error type.
62
66
///
63
67
/// This tuple struct is made of two elements:
@@ -67,7 +71,7 @@ macro_rules! error_chain_processed {
67
71
/// internals, containing:
68
72
/// - a backtrace, generated when the error is created.
69
73
/// - an error chain, used for the implementation of `Error::cause()`.
70
- #[ derive( Debug ) ]
74
+ #[ derive( Debug , $ ( $bound ) , * ) ]
71
75
pub struct $error_name(
72
76
// The members must be `pub` for `links`.
73
77
/// The kind of the error.
@@ -256,7 +260,7 @@ macro_rules! error_chain_processed {
256
260
257
261
quick_error! {
258
262
/// The kind of an error.
259
- #[ derive( Debug ) ]
263
+ #[ derive( Debug , $ ( $bound ) , * ) ]
260
264
pub enum $error_kind_name {
261
265
262
266
/// A convenient variant for String.
@@ -427,6 +431,19 @@ macro_rules! error_chain {
427
431
} ;
428
432
}
429
433
434
+ /// Macro used to generate traits with `Self` bounds
435
+ #[ macro_export]
436
+ #[ doc( hidden) ]
437
+ macro_rules! create_super_trait {
438
+ ( $name: ident: $( $bound: ident) ,* ) => {
439
+ create_super_trait!( $name: $( $bound +) * ) ;
440
+ } ;
441
+ ( $name: ident: $bound_1: ident + $( $bound_2: tt +) * ) => {
442
+ trait $name: $bound_1 $( + $bound_2) * { }
443
+ impl <T : $bound_1 $( + $bound_2) * > $name for T { }
444
+ } ;
445
+ }
446
+
430
447
/// Macro used to manage the `backtrace` feature.
431
448
///
432
449
/// See
0 commit comments