@@ -379,32 +379,33 @@ pub trait ChainedError: error::Error + Send + 'static {
379379}
380380
381381/// Additionnal methods for `Result`, for easy interaction with this crate.
382- pub trait ResultExt < T , E : ChainedError > {
382+ pub trait ResultExt < T , E , CE : ChainedError > {
383383 /// If the `Result` is an `Err` then `chain_err` evaluates the closure,
384384 /// which returns *some type that can be converted to `ErrorKind`*, boxes
385385 /// the original error to store as the cause, then returns a new error
386386 /// containing the original error.
387- fn chain_err < F , EK > ( self , callback : F ) -> Result < T , E >
387+ fn chain_err < F , EK > ( self , callback : F ) -> Result < T , CE >
388388 where F : FnOnce ( ) -> EK ,
389- EK : Into < E :: ErrorKind > ;
389+ EK : Into < CE :: ErrorKind > ;
390390}
391391
392- impl < T , E > ResultExt < T , E > for Result < T , E > where E : ChainedError {
393- fn chain_err < F , EK > ( self , callback : F ) -> Result < T , E >
392+ impl < T , E , CE > ResultExt < T , E , CE > for Result < T , E > where CE : ChainedError , E : Into < CE > {
393+ fn chain_err < F , EK > ( self , callback : F ) -> Result < T , CE >
394394 where F : FnOnce ( ) -> EK ,
395- EK : Into < E :: ErrorKind > {
395+ EK : Into < CE :: ErrorKind > {
396396 self . map_err ( move |e| {
397+ let e = e. into ( ) ;
397398 #[ cfg( feature = "backtrace" ) ]
398399 let error = {
399- let backtrace = E :: extract_backtrace ( & e)
400+ let backtrace = CE :: extract_backtrace ( & e)
400401 . unwrap_or_else ( make_backtrace) ;
401- E :: new ( callback ( ) . into ( ) , State {
402+ CE :: new ( callback ( ) . into ( ) , State {
402403 next_error : Some ( Box :: new ( e) ) ,
403404 backtrace : backtrace,
404405 } )
405406 } ;
406407 #[ cfg( not( feature = "backtrace" ) ) ]
407- let error = E :: new ( callback ( ) . into ( ) , State {
408+ let error = CE :: new ( callback ( ) . into ( ) , State {
408409 next_error : Some ( Box :: new ( e) ) ,
409410 } ) ;
410411 error
0 commit comments