File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ use std:: convert:: Infallible ;
2
+
3
+ impl crate :: de:: Error for Infallible {
4
+ fn custom < T > ( msg : T ) -> Self
5
+ where
6
+ T : std:: fmt:: Display ,
7
+ {
8
+ panic ! ( "Infallible error: {msg}" ) ;
9
+ }
10
+
11
+ fn wrong_name ( name : & crate :: ExpandedName < ' _ > , expected : & crate :: ExpandedName < ' _ > ) -> Self {
12
+ panic ! ( "Infallible error: wrong name \" {name}\" , expected \" {expected}\" " ) ;
13
+ }
14
+
15
+ fn unexpected_visit < T > ( unexpected : crate :: de:: Unexpected , _expected : & T ) -> Self {
16
+ panic ! ( "Infallible error: unexpected visit of {unexpected}" ) ;
17
+ }
18
+
19
+ fn missing_field ( field : & str ) -> Self {
20
+ panic ! ( "Infallible error: missing field {field}" ) ;
21
+ }
22
+
23
+ fn no_possible_variant ( ident : & str ) -> Self {
24
+ panic ! ( "Infallible error: no possible variant {ident}" ) ;
25
+ }
26
+
27
+ fn missing_data ( ) -> Self {
28
+ panic ! ( "Infallible error: missing data" ) ;
29
+ }
30
+
31
+ fn unknown_child ( ) -> Self {
32
+ panic ! ( "Infallible error: unknown child" ) ;
33
+ }
34
+
35
+ fn invalid_string ( ) -> Self {
36
+ panic ! ( "Infallible error: invalid string" ) ;
37
+ }
38
+ }
39
+
40
+ impl crate :: ser:: Error for Infallible {
41
+ fn custom < T > ( msg : T ) -> Self
42
+ where
43
+ T : std:: fmt:: Display ,
44
+ {
45
+ panic ! ( "Infallible error: {msg}" ) ;
46
+ }
47
+
48
+ fn unexpected_serialize ( unexpected : crate :: ser:: Unexpected ) -> Self {
49
+ panic ! ( "Infallible error: unexpected serialize of {unexpected}" ) ;
50
+ }
51
+ }
Original file line number Diff line number Diff line change 3
3
//! It also contains some visitors for the types which can be reused, including [`iterator::IteratorVisitor`].
4
4
5
5
pub mod common;
6
+ mod infallible;
6
7
pub mod iterator;
7
8
mod primitive;
8
9
mod smart;
You can’t perform that action at this time.
0 commit comments