1
- use std;
1
+ use std:: { self , fmt, error} ;
2
+
3
+
4
+ #[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
5
+ /// Copy of [TryFromIntError](https://doc.rust-lang.org/std/num/struct.TryFromIntError.html)
6
+ /// that works in stable rust
7
+ pub struct TryFromIntError { }
8
+
9
+ impl TryFromIntError {
10
+ fn description ( & self ) -> & str {
11
+ "out of range integral type conversion attempted"
12
+ }
13
+ }
14
+
15
+ impl fmt:: Display for TryFromIntError {
16
+ fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
17
+ self . description ( ) . fmt ( fmt)
18
+ }
19
+ }
20
+
21
+ impl error:: Error for TryFromIntError {
22
+ fn description ( & self ) -> & str {
23
+ self . description ( )
24
+ }
25
+ }
26
+
27
+ #[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
28
+ /// Copy of [CharTryFromError](https://doc.rust-lang.org/std/char/struct.CharTryFromError.html)
29
+ /// that works in stable rust
30
+ pub struct CharTryFromError { }
31
+
32
+ impl CharTryFromError {
33
+ fn description ( & self ) -> & str {
34
+ "converted integer out of range for `char`"
35
+ }
36
+ }
37
+
38
+ impl fmt:: Display for CharTryFromError {
39
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
40
+ self . description ( ) . fmt ( f)
41
+ }
42
+ }
43
+
44
+ impl error:: Error for CharTryFromError {
45
+ fn description ( & self ) -> & str {
46
+ self . description ( )
47
+ }
48
+ }
2
49
3
50
error_chain ! {
4
51
types {
@@ -8,8 +55,8 @@ error_chain! {
8
55
foreign_links {
9
56
Io ( std:: io:: Error ) ;
10
57
FromUtf8 ( std:: string:: FromUtf8Error ) ;
11
- TryFromIntError ( std :: num :: TryFromIntError ) ;
12
- CharTryFromError ( std :: char :: CharTryFromError ) ;
58
+ TryFromIntError ( TryFromIntError ) ;
59
+ CharTryFromError ( CharTryFromError ) ;
13
60
14
61
UuidParseError ( :: uuid:: ParseError ) #[ cfg( feature = "uuid" ) ] ;
15
62
}
0 commit comments