@@ -68,104 +68,104 @@ impl error::Error for Error {
68
68
#[ cold]
69
69
fn source ( & self ) -> Option < & ( dyn error:: Error + ' static ) > {
70
70
match * self {
71
- Error :: TypeMismatch ( ..) => None ,
72
- Error :: InvalidMarkerRead ( ref err) => Some ( err) ,
73
- Error :: InvalidDataRead ( ref err) => Some ( err) ,
74
- Error :: LengthMismatch ( ..) => None ,
75
- Error :: OutOfRange => None ,
76
- Error :: Uncategorized ( ..) => None ,
77
- Error :: Syntax ( ..) => None ,
78
- Error :: Utf8Error ( ref err) => Some ( err) ,
79
- Error :: DepthLimitExceeded => None ,
71
+ Self :: TypeMismatch ( ..) => None ,
72
+ Self :: InvalidMarkerRead ( ref err) => Some ( err) ,
73
+ Self :: InvalidDataRead ( ref err) => Some ( err) ,
74
+ Self :: LengthMismatch ( ..) => None ,
75
+ Self :: OutOfRange => None ,
76
+ Self :: Uncategorized ( ..) => None ,
77
+ Self :: Syntax ( ..) => None ,
78
+ Self :: Utf8Error ( ref err) => Some ( err) ,
79
+ Self :: DepthLimitExceeded => None ,
80
80
}
81
81
}
82
82
}
83
83
84
84
impl de:: Error for Error {
85
85
#[ cold]
86
86
fn custom < T : Display > ( msg : T ) -> Self {
87
- Error :: Syntax ( msg. to_string ( ) )
87
+ Self :: Syntax ( msg. to_string ( ) )
88
88
}
89
89
}
90
90
91
91
impl Display for Error {
92
92
#[ cold]
93
93
fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> Result < ( ) , fmt:: Error > {
94
94
match * self {
95
- Error :: InvalidMarkerRead ( ref err) => write ! ( fmt, "IO error while reading marker: {err}" ) ,
96
- Error :: InvalidDataRead ( ref err) => write ! ( fmt, "IO error while reading data: {err}" ) ,
97
- Error :: TypeMismatch ( ref actual_marker) => {
95
+ Self :: InvalidMarkerRead ( ref err) => write ! ( fmt, "IO error while reading marker: {err}" ) ,
96
+ Self :: InvalidDataRead ( ref err) => write ! ( fmt, "IO error while reading data: {err}" ) ,
97
+ Self :: TypeMismatch ( ref actual_marker) => {
98
98
write ! ( fmt, "wrong msgpack marker {actual_marker:?}" )
99
99
}
100
- Error :: OutOfRange => fmt. write_str ( "numeric cast found out of range" ) ,
101
- Error :: LengthMismatch ( expected_length) => write ! (
100
+ Self :: OutOfRange => fmt. write_str ( "numeric cast found out of range" ) ,
101
+ Self :: LengthMismatch ( expected_length) => write ! (
102
102
fmt,
103
103
"array had incorrect length, expected {expected_length}"
104
104
) ,
105
- Error :: Uncategorized ( ref msg) => write ! ( fmt, "uncategorized error: {msg}" ) ,
106
- Error :: Syntax ( ref msg) => fmt. write_str ( msg) ,
107
- Error :: Utf8Error ( ref err) => write ! ( fmt, "string found to be invalid utf8: {err}" ) ,
108
- Error :: DepthLimitExceeded => fmt. write_str ( "depth limit exceeded" ) ,
105
+ Self :: Uncategorized ( ref msg) => write ! ( fmt, "uncategorized error: {msg}" ) ,
106
+ Self :: Syntax ( ref msg) => fmt. write_str ( msg) ,
107
+ Self :: Utf8Error ( ref err) => write ! ( fmt, "string found to be invalid utf8: {err}" ) ,
108
+ Self :: DepthLimitExceeded => fmt. write_str ( "depth limit exceeded" ) ,
109
109
}
110
110
}
111
111
}
112
112
113
113
impl From < MarkerReadError > for Error {
114
114
#[ cold]
115
- fn from ( err : MarkerReadError ) -> Error {
115
+ fn from ( err : MarkerReadError ) -> Self {
116
116
match err {
117
- MarkerReadError ( err) => Error :: InvalidMarkerRead ( err) ,
117
+ MarkerReadError ( err) => Self :: InvalidMarkerRead ( err) ,
118
118
}
119
119
}
120
120
}
121
121
122
122
impl From < Utf8Error > for Error {
123
123
#[ cold]
124
- fn from ( err : Utf8Error ) -> Error {
125
- Error :: Utf8Error ( err)
124
+ fn from ( err : Utf8Error ) -> Self {
125
+ Self :: Utf8Error ( err)
126
126
}
127
127
}
128
128
129
129
impl From < ValueReadError > for Error {
130
130
#[ cold]
131
- fn from ( err : ValueReadError ) -> Error {
131
+ fn from ( err : ValueReadError ) -> Self {
132
132
match err {
133
- ValueReadError :: TypeMismatch ( marker) => Error :: TypeMismatch ( marker) ,
134
- ValueReadError :: InvalidMarkerRead ( err) => Error :: InvalidMarkerRead ( err) ,
135
- ValueReadError :: InvalidDataRead ( err) => Error :: InvalidDataRead ( err) ,
133
+ ValueReadError :: TypeMismatch ( marker) => Self :: TypeMismatch ( marker) ,
134
+ ValueReadError :: InvalidMarkerRead ( err) => Self :: InvalidMarkerRead ( err) ,
135
+ ValueReadError :: InvalidDataRead ( err) => Self :: InvalidDataRead ( err) ,
136
136
}
137
137
}
138
138
}
139
139
140
140
impl From < NumValueReadError > for Error {
141
141
#[ cold]
142
- fn from ( err : NumValueReadError ) -> Error {
142
+ fn from ( err : NumValueReadError ) -> Self {
143
143
match err {
144
- NumValueReadError :: TypeMismatch ( marker) => Error :: TypeMismatch ( marker) ,
145
- NumValueReadError :: InvalidMarkerRead ( err) => Error :: InvalidMarkerRead ( err) ,
146
- NumValueReadError :: InvalidDataRead ( err) => Error :: InvalidDataRead ( err) ,
147
- NumValueReadError :: OutOfRange => Error :: OutOfRange ,
144
+ NumValueReadError :: TypeMismatch ( marker) => Self :: TypeMismatch ( marker) ,
145
+ NumValueReadError :: InvalidMarkerRead ( err) => Self :: InvalidMarkerRead ( err) ,
146
+ NumValueReadError :: InvalidDataRead ( err) => Self :: InvalidDataRead ( err) ,
147
+ NumValueReadError :: OutOfRange => Self :: OutOfRange ,
148
148
}
149
149
}
150
150
}
151
151
152
- impl < ' a > From < DecodeStringError < ' a > > for Error {
152
+ impl From < DecodeStringError < ' _ > > for Error {
153
153
#[ cold]
154
- fn from ( err : DecodeStringError < ' _ > ) -> Error {
154
+ fn from ( err : DecodeStringError < ' _ > ) -> Self {
155
155
match err {
156
- DecodeStringError :: InvalidMarkerRead ( err) => Error :: InvalidMarkerRead ( err) ,
157
- DecodeStringError :: InvalidDataRead ( err) => Error :: InvalidDataRead ( err) ,
158
- DecodeStringError :: TypeMismatch ( marker) => Error :: TypeMismatch ( marker) ,
159
- DecodeStringError :: BufferSizeTooSmall ( ..) => Error :: Uncategorized ( "BufferSizeTooSmall" . to_string ( ) ) ,
160
- DecodeStringError :: InvalidUtf8 ( ..) => Error :: Uncategorized ( "InvalidUtf8" . to_string ( ) ) ,
156
+ DecodeStringError :: InvalidMarkerRead ( err) => Self :: InvalidMarkerRead ( err) ,
157
+ DecodeStringError :: InvalidDataRead ( err) => Self :: InvalidDataRead ( err) ,
158
+ DecodeStringError :: TypeMismatch ( marker) => Self :: TypeMismatch ( marker) ,
159
+ DecodeStringError :: BufferSizeTooSmall ( ..) => Self :: Uncategorized ( "BufferSizeTooSmall" . to_string ( ) ) ,
160
+ DecodeStringError :: InvalidUtf8 ( ..) => Self :: Uncategorized ( "InvalidUtf8" . to_string ( ) ) ,
161
161
}
162
162
}
163
163
}
164
164
165
165
impl From < TryFromIntError > for Error {
166
166
#[ cold]
167
167
fn from ( _: TryFromIntError ) -> Self {
168
- Error :: OutOfRange
168
+ Self :: OutOfRange
169
169
}
170
170
}
171
171
@@ -246,7 +246,7 @@ impl<R: Read, C: SerializerConfig> Deserializer<R, C> {
246
246
/// versions of `rmp-serde`.
247
247
#[ inline]
248
248
pub fn with_human_readable ( self ) -> Deserializer < R , HumanReadableConfig < C > > {
249
- let Deserializer { rd, _config : _, is_human_readable : _, marker, depth } = self ;
249
+ let Self { rd, _config : _, is_human_readable : _, marker, depth } = self ;
250
250
Deserializer {
251
251
rd,
252
252
is_human_readable : true ,
@@ -263,7 +263,7 @@ impl<R: Read, C: SerializerConfig> Deserializer<R, C> {
263
263
/// representation.
264
264
#[ inline]
265
265
pub fn with_binary ( self ) -> Deserializer < R , BinaryConfig < C > > {
266
- let Deserializer { rd, _config : _, is_human_readable : _, marker, depth } = self ;
266
+ let Self { rd, _config : _, is_human_readable : _, marker, depth } = self ;
267
267
Deserializer {
268
268
rd,
269
269
is_human_readable : false ,
@@ -331,9 +331,7 @@ fn read_i128_marker<'de, R: ReadSlice<'de>>(marker: Marker, rd: &mut R) -> Resul
331
331
let len = read_u8 ( & mut * rd) ?;
332
332
read_128_buf ( rd, len) ?
333
333
} ,
334
- Marker :: FixArray ( len) => {
335
- read_128_buf ( rd, len) ?
336
- } ,
334
+ Marker :: FixArray ( len) => read_128_buf ( rd, len) ?,
337
335
marker => return Err ( Error :: TypeMismatch ( marker) ) ,
338
336
} )
339
337
}
@@ -428,7 +426,7 @@ struct ExtDeserializer<'a, R, C> {
428
426
}
429
427
430
428
impl < ' de , ' a , R : ReadSlice < ' de > + ' a , C : SerializerConfig > ExtDeserializer < ' a , R , C > {
431
- fn new ( d : & ' a mut Deserializer < R , C > , len : u32 ) -> Self {
429
+ const fn new ( d : & ' a mut Deserializer < R , C > , len : u32 ) -> Self {
432
430
ExtDeserializer {
433
431
rd : & mut d. rd ,
434
432
_config : d. _config ,
@@ -551,7 +549,7 @@ impl<'de, R: ReadSlice<'de>, C: SerializerConfig> Deserializer<R, C> {
551
549
Marker :: FixStr ( len) => Ok ( len. into ( ) ) ,
552
550
Marker :: Str8 => read_u8 ( & mut self . rd ) . map ( u32:: from) ,
553
551
Marker :: Str16 => read_u16 ( & mut self . rd ) . map ( u32:: from) ,
554
- Marker :: Str32 => read_u32 ( & mut self . rd ) . map ( u32 :: from ) ,
552
+ Marker :: Str32 => read_u32 ( & mut self . rd ) ,
555
553
_ => return Err ( Error :: TypeMismatch ( Marker :: Reserved ) ) ,
556
554
} ?;
557
555
read_str_data ( & mut self . rd , len, visitor)
@@ -598,7 +596,7 @@ impl<'de, R: ReadSlice<'de>, C: SerializerConfig> Deserializer<R, C> {
598
596
let len = match marker {
599
597
Marker :: Bin8 => read_u8 ( & mut self . rd ) . map ( u32:: from) ,
600
598
Marker :: Bin16 => read_u16 ( & mut self . rd ) . map ( u32:: from) ,
601
- Marker :: Bin32 => read_u32 ( & mut self . rd ) . map ( u32 :: from ) ,
599
+ Marker :: Bin32 => read_u32 ( & mut self . rd ) ,
602
600
_ => return Err ( Error :: TypeMismatch ( Marker :: Reserved ) ) ,
603
601
} ?;
604
602
match read_bin_data ( & mut self . rd , len) ? {
@@ -625,7 +623,7 @@ impl<'de, R: ReadSlice<'de>, C: SerializerConfig> Deserializer<R, C> {
625
623
}
626
624
}
627
625
628
- impl < ' de , ' a , R : ReadSlice < ' de > , C : SerializerConfig > serde:: Deserializer < ' de > for & ' a mut Deserializer < R , C > {
626
+ impl < ' de , R : ReadSlice < ' de > , C : SerializerConfig > serde:: Deserializer < ' de > for & mut Deserializer < R , C > {
629
627
type Error = Error ;
630
628
631
629
#[ inline( always) ]
@@ -821,7 +819,7 @@ struct SeqAccess<'a, R, C> {
821
819
822
820
impl < ' a , R : ' a , C > SeqAccess < ' a , R , C > {
823
821
#[ inline]
824
- fn new ( de : & ' a mut Deserializer < R , C > , len : u32 ) -> Self {
822
+ const fn new ( de : & ' a mut Deserializer < R , C > , len : u32 ) -> Self {
825
823
SeqAccess { de, left : len }
826
824
}
827
825
}
@@ -854,7 +852,7 @@ struct MapAccess<'a, R, C> {
854
852
855
853
impl < ' a , R : ' a , C > MapAccess < ' a , R , C > {
856
854
#[ inline]
857
- fn new ( de : & ' a mut Deserializer < R , C > , len : u32 ) -> Self {
855
+ const fn new ( de : & ' a mut Deserializer < R , C > , len : u32 ) -> Self {
858
856
MapAccess { de, left : len }
859
857
}
860
858
}
@@ -892,13 +890,13 @@ struct UnitVariantAccess<'a, R: 'a, C> {
892
890
}
893
891
894
892
impl < ' a , R : ' a , C > UnitVariantAccess < ' a , R , C > {
895
- pub fn new ( de : & ' a mut Deserializer < R , C > ) -> Self {
893
+ pub const fn new ( de : & ' a mut Deserializer < R , C > ) -> Self {
896
894
UnitVariantAccess { de }
897
895
}
898
896
}
899
897
900
- impl < ' de , ' a , R : ReadSlice < ' de > , C : SerializerConfig > de:: EnumAccess < ' de >
901
- for UnitVariantAccess < ' a , R , C >
898
+ impl < ' de , R : ReadSlice < ' de > , C : SerializerConfig > de:: EnumAccess < ' de >
899
+ for UnitVariantAccess < ' _ , R , C >
902
900
{
903
901
type Error = Error ;
904
902
type Variant = Self ;
@@ -962,12 +960,12 @@ struct VariantAccess<'a, R, C> {
962
960
}
963
961
964
962
impl < ' a , R : ' a , C > VariantAccess < ' a , R , C > {
965
- pub fn new ( de : & ' a mut Deserializer < R , C > ) -> Self {
963
+ pub const fn new ( de : & ' a mut Deserializer < R , C > ) -> Self {
966
964
VariantAccess { de }
967
965
}
968
966
}
969
967
970
- impl < ' de , ' a , R : ReadSlice < ' de > , C : SerializerConfig > de:: EnumAccess < ' de > for VariantAccess < ' a , R , C > {
968
+ impl < ' de , R : ReadSlice < ' de > , C : SerializerConfig > de:: EnumAccess < ' de > for VariantAccess < ' _ , R , C > {
971
969
type Error = Error ;
972
970
type Variant = Self ;
973
971
@@ -979,7 +977,7 @@ impl<'de, 'a, R: ReadSlice<'de>, C: SerializerConfig> de::EnumAccess<'de> for Va
979
977
}
980
978
}
981
979
982
- impl < ' de , ' a , R : ReadSlice < ' de > , C : SerializerConfig > de:: VariantAccess < ' de > for VariantAccess < ' a , R , C > {
980
+ impl < ' de , R : ReadSlice < ' de > , C : SerializerConfig > de:: VariantAccess < ' de > for VariantAccess < ' _ , R , C > {
983
981
type Error = Error ;
984
982
985
983
#[ inline]
@@ -1037,7 +1035,7 @@ pub struct ReadReader<R: Read> {
1037
1035
impl < R : Read > ReadReader < R > {
1038
1036
#[ inline]
1039
1037
fn new ( rd : R ) -> Self {
1040
- ReadReader {
1038
+ Self {
1041
1039
rd,
1042
1040
buf : Vec :: with_capacity ( 128 ) ,
1043
1041
}
@@ -1079,7 +1077,7 @@ pub struct ReadRefReader<'a, R: ?Sized> {
1079
1077
impl < ' a , T > ReadRefReader < ' a , T > {
1080
1078
/// Returns the part that hasn't been consumed yet
1081
1079
#[ must_use]
1082
- pub fn remaining_slice ( & self ) -> & ' a [ u8 ] {
1080
+ pub const fn remaining_slice ( & self ) -> & ' a [ u8 ] {
1083
1081
self . buf
1084
1082
}
1085
1083
}
@@ -1094,7 +1092,7 @@ impl<'a, T: AsRef<[u8]> + ?Sized> ReadRefReader<'a, T> {
1094
1092
}
1095
1093
}
1096
1094
1097
- impl < ' a , T : AsRef < [ u8 ] > + ?Sized > Read for ReadRefReader < ' a , T > {
1095
+ impl < T : AsRef < [ u8 ] > + ?Sized > Read for ReadRefReader < ' _ , T > {
1098
1096
#[ inline]
1099
1097
fn read ( & mut self , buf : & mut [ u8 ] ) -> Result < usize , io:: Error > {
1100
1098
self . buf . read ( buf)
0 commit comments