File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -313,6 +313,8 @@ mod content {
313
313
}
314
314
}
315
315
316
+ /// Used to capture data in [`Content`] from other deserializers.
317
+ /// Cannot capture externally tagged enums, `i128` and `u128`.
316
318
struct ContentVisitor < ' de > {
317
319
value : PhantomData < Content < ' de > > ,
318
320
}
@@ -528,6 +530,8 @@ mod content {
528
530
Content ( Content < ' de > ) ,
529
531
}
530
532
533
+ /// Serves as a seed for deserializing a key of internally tagged enum.
534
+ /// Cannot capture externally tagged enums, `i128` and `u128`.
531
535
struct TagOrContentVisitor < ' de > {
532
536
name : & ' static str ,
533
537
value : PhantomData < TagOrContent < ' de > > ,
@@ -814,6 +818,9 @@ mod content {
814
818
815
819
/// Used by generated code to deserialize an internally tagged enum.
816
820
///
821
+ /// Captures map or sequence from the original deserializer and searches
822
+ /// a tag in it (in case of sequence, tag is the first element of sequence).
823
+ ///
817
824
/// Not public API.
818
825
pub struct TaggedContentVisitor < T > {
819
826
tag_name : & ' static str ,
Original file line number Diff line number Diff line change @@ -1081,6 +1081,15 @@ fn test_internally_tagged_struct_variant_containing_unit_variant() {
1081
1081
Log { level : Level } ,
1082
1082
}
1083
1083
1084
+ assert_de_tokens (
1085
+ & Level :: Info ,
1086
+ & [
1087
+ Token :: Enum { name : "Level" } ,
1088
+ Token :: BorrowedStr ( "Info" ) ,
1089
+ Token :: Unit ,
1090
+ ] ,
1091
+ ) ;
1092
+
1084
1093
assert_de_tokens (
1085
1094
& Message :: Log { level : Level :: Info } ,
1086
1095
& [
@@ -1091,7 +1100,9 @@ fn test_internally_tagged_struct_variant_containing_unit_variant() {
1091
1100
Token :: Str ( "action" ) ,
1092
1101
Token :: Str ( "Log" ) ,
1093
1102
Token :: Str ( "level" ) ,
1103
+ Token :: Enum { name : "Level" } ,
1094
1104
Token :: BorrowedStr ( "Info" ) ,
1105
+ Token :: Unit ,
1095
1106
Token :: StructEnd ,
1096
1107
] ,
1097
1108
) ;
@@ -1103,7 +1114,9 @@ fn test_internally_tagged_struct_variant_containing_unit_variant() {
1103
1114
Token :: Str ( "action" ) ,
1104
1115
Token :: Str ( "Log" ) ,
1105
1116
Token :: Str ( "level" ) ,
1117
+ Token :: Enum { name : "Level" } ,
1106
1118
Token :: BorrowedStr ( "Info" ) ,
1119
+ Token :: Unit ,
1107
1120
Token :: MapEnd ,
1108
1121
] ,
1109
1122
) ;
@@ -1113,7 +1126,9 @@ fn test_internally_tagged_struct_variant_containing_unit_variant() {
1113
1126
& [
1114
1127
Token :: Seq { len : Some ( 2 ) } ,
1115
1128
Token :: Str ( "Log" ) ,
1129
+ Token :: Enum { name : "Level" } ,
1116
1130
Token :: BorrowedStr ( "Info" ) ,
1131
+ Token :: Unit ,
1117
1132
Token :: SeqEnd ,
1118
1133
] ,
1119
1134
) ;
You can’t perform that action at this time.
0 commit comments