540
540
//! [`BacktraceFrame`]: https://docs.rs/backtrace/0.3.2/backtrace/struct.BacktraceFrame.html
541
541
542
542
use std:: error;
543
- use std:: iter:: Iterator ;
544
543
use std:: fmt;
544
+ use std:: iter:: Iterator ;
545
545
546
546
#[ macro_use]
547
547
mod impl_error_chain_kind;
@@ -550,9 +550,9 @@ mod error_chain;
550
550
#[ macro_use]
551
551
mod quick_main;
552
552
pub use quick_main:: ExitCode ;
553
+ mod backtrace;
553
554
#[ cfg( feature = "example_generated" ) ]
554
555
pub mod example_generated;
555
- mod backtrace;
556
556
pub use backtrace:: Backtrace ;
557
557
#[ doc( hidden) ]
558
558
pub use backtrace:: InternalBacktrace ;
@@ -597,13 +597,16 @@ pub trait ChainedError: error::Error + Send + 'static {
597
597
type ErrorKind ;
598
598
599
599
/// Constructs an error from a kind, and generates a backtrace.
600
- fn from_kind ( kind : Self :: ErrorKind ) -> Self where Self : Sized ;
600
+ fn from_kind ( kind : Self :: ErrorKind ) -> Self
601
+ where
602
+ Self : Sized ;
601
603
602
604
/// Constructs a chained error from another error and a kind, and generates a backtrace.
603
605
fn with_chain < E , K > ( error : E , kind : K ) -> Self
604
- where Self : Sized ,
605
- E : :: std:: error:: Error + Send + ' static ,
606
- K : Into < Self :: ErrorKind > ;
606
+ where
607
+ Self : Sized ,
608
+ E : :: std:: error:: Error + Send + ' static ,
609
+ K : Into < Self :: ErrorKind > ;
607
610
608
611
/// Returns the kind of the error.
609
612
fn kind ( & self ) -> & Self :: ErrorKind ;
@@ -624,27 +627,32 @@ pub trait ChainedError: error::Error + Send + 'static {
624
627
625
628
/// Extends the error chain with a new entry.
626
629
fn chain_err < F , EK > ( self , error : F ) -> Self
627
- where F : FnOnce ( ) -> EK ,
628
- EK : Into < Self :: ErrorKind > ;
630
+ where
631
+ F : FnOnce ( ) -> EK ,
632
+ EK : Into < Self :: ErrorKind > ;
629
633
630
634
/// Creates an error from its parts.
631
635
#[ doc( hidden) ]
632
- fn new ( kind : Self :: ErrorKind , state : State ) -> Self where Self : Sized ;
636
+ fn new ( kind : Self :: ErrorKind , state : State ) -> Self
637
+ where
638
+ Self : Sized ;
633
639
634
640
/// Returns the first known backtrace, either from its State or from one
635
641
/// of the errors from `foreign_links`.
636
642
#[ doc( hidden) ]
637
643
#[ allow( unknown_lints, bare_trait_objects) ]
638
644
fn extract_backtrace ( e : & ( error:: Error + Send + ' static ) ) -> Option < InternalBacktrace >
639
- where Self : Sized ;
645
+ where
646
+ Self : Sized ;
640
647
}
641
648
642
649
/// A struct which formats an error for output.
643
650
#[ derive( Debug ) ]
644
651
pub struct DisplayChain < ' a , T : ' a + ?Sized > ( & ' a T ) ;
645
652
646
653
impl < ' a , T > fmt:: Display for DisplayChain < ' a , T >
647
- where T : ChainedError
654
+ where
655
+ T : ChainedError ,
648
656
{
649
657
fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
650
658
writeln ! ( fmt, "Error: {}" , self . 0 ) ?;
@@ -685,8 +693,7 @@ impl State {
685
693
/// Creates a new State type
686
694
#[ allow( unknown_lints, bare_trait_objects) ]
687
695
pub fn new < CE : ChainedError > ( e : Box < error:: Error + Send > ) -> State {
688
- let backtrace = CE :: extract_backtrace ( & * e)
689
- . unwrap_or_else ( InternalBacktrace :: new) ;
696
+ let backtrace = CE :: extract_backtrace ( & * e) . unwrap_or_else ( InternalBacktrace :: new) ;
690
697
State {
691
698
next_error : Some ( e) ,
692
699
backtrace : backtrace,
@@ -813,5 +820,5 @@ macro_rules! ensure {
813
820
814
821
#[ doc( hidden) ]
815
822
pub mod mock {
816
- error_chain ! { }
823
+ error_chain ! { }
817
824
}
0 commit comments