@@ -40,7 +40,7 @@ macro_rules! error_chain_processed {
4040 }
4141
4242 derive {
43- $( $trait : ident) ,*
43+ $( $bound : ident) ,*
4444 }
4545
4646 links {
@@ -58,6 +58,10 @@ macro_rules! error_chain_processed {
5858 }
5959
6060 ) => {
61+ use :: std:: fmt:: Debug ;
62+ use :: std:: error:: Error as StdError ;
63+ create_super_trait!( Trait : Debug , StdError , Send $( , $bound) * ) ;
64+
6165 /// The Error type.
6266 ///
6367 /// This tuple struct is made of two elements:
@@ -67,7 +71,7 @@ macro_rules! error_chain_processed {
6771 /// internals, containing:
6872 /// - a backtrace, generated when the error is created.
6973 /// - an error chain, used for the implementation of `Error::cause()`.
70- #[ derive( Debug ) ]
74+ #[ derive( Debug , $ ( $bound ) , * ) ]
7175 pub struct $error_name(
7276 // The members must be `pub` for `links`.
7377 /// The kind of the error.
@@ -247,7 +251,7 @@ macro_rules! error_chain_processed {
247251
248252 quick_error! {
249253 /// The kind of an error.
250- #[ derive( Debug ) ]
254+ #[ derive( Debug , $ ( $bound ) , * ) ]
251255 pub enum $error_kind_name {
252256
253257 /// A convenient variant for String.
@@ -408,6 +412,19 @@ macro_rules! error_chain {
408412 } ;
409413}
410414
415+ /// Macro used to generate traits with `Self` bounds
416+ #[ macro_export]
417+ #[ doc( hidden) ]
418+ macro_rules! create_super_trait {
419+ ( $name: ident: $( $bound: ident) ,* ) => {
420+ create_super_trait!( $name: $( $bound +) * ) ;
421+ } ;
422+ ( $name: ident: $bound_1: ident + $( $bound_2: tt +) * ) => {
423+ trait $name: $bound_1 $( + $bound_2) * { }
424+ impl <T : $bound_1 $( + $bound_2) * > $name for T { }
425+ } ;
426+ }
427+
411428/// Macro used to manage the `backtrace` feature.
412429///
413430/// See
0 commit comments