This repository was archived by the owner on Aug 16, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,12 @@ with_std! {
39
39
}
40
40
}
41
41
42
+ impl From <Error > for Box <StdError > {
43
+ fn from( error: Error ) -> Box <StdError > {
44
+ Box :: new( Compat { error } )
45
+ }
46
+ }
47
+
42
48
impl From <Error > for Box <StdError + Send + Sync > {
43
49
fn from( error: Error ) -> Box <StdError + Send + Sync > {
44
50
Box :: new( Compat { error } )
Original file line number Diff line number Diff line change
1
+ #[ macro_use]
2
+ extern crate failure;
3
+
4
+ use failure:: Fail ;
5
+
6
+ fn return_failure ( ) -> Result < ( ) , failure:: Error > {
7
+ #[ derive( Fail , Debug ) ]
8
+ #[ fail( display = "my error" ) ]
9
+ struct MyError ;
10
+
11
+ let err = MyError ;
12
+ Err ( err. into ( ) )
13
+ }
14
+
15
+ fn return_error ( ) -> Result < ( ) , Box < std:: error:: Error > > {
16
+ return_failure ( ) ?;
17
+ Ok ( ( ) )
18
+ }
19
+
20
+ fn return_error_send_sync ( ) -> Result < ( ) , Box < std:: error:: Error + Send + Sync > > {
21
+ return_failure ( ) ?;
22
+ Ok ( ( ) )
23
+ }
24
+
25
+ #[ test]
26
+ fn smoke_default_compat ( ) {
27
+ let err = return_error ( ) ;
28
+ assert ! ( err. is_err( ) ) ;
29
+ }
30
+
31
+ #[ test]
32
+ fn smoke_compat_send_sync ( ) {
33
+ let err = return_error_send_sync ( ) ;
34
+ assert ! ( err. is_err( ) ) ;
35
+ }
You can’t perform that action at this time.
0 commit comments