@@ -68,104 +68,104 @@ impl error::Error for Error {
6868 #[ cold]
6969 fn source ( & self ) -> Option < & ( dyn error:: Error + ' static ) > {
7070 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 ,
8080 }
8181 }
8282}
8383
8484impl de:: Error for Error {
8585 #[ cold]
8686 fn custom < T : Display > ( msg : T ) -> Self {
87- Error :: Syntax ( msg. to_string ( ) )
87+ Self :: Syntax ( msg. to_string ( ) )
8888 }
8989}
9090
9191impl Display for Error {
9292 #[ cold]
9393 fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> Result < ( ) , fmt:: Error > {
9494 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) => {
9898 write ! ( fmt, "wrong msgpack marker {actual_marker:?}" )
9999 }
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 ! (
102102 fmt,
103103 "array had incorrect length, expected {expected_length}"
104104 ) ,
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" ) ,
109109 }
110110 }
111111}
112112
113113impl From < MarkerReadError > for Error {
114114 #[ cold]
115- fn from ( err : MarkerReadError ) -> Error {
115+ fn from ( err : MarkerReadError ) -> Self {
116116 match err {
117- MarkerReadError ( err) => Error :: InvalidMarkerRead ( err) ,
117+ MarkerReadError ( err) => Self :: InvalidMarkerRead ( err) ,
118118 }
119119 }
120120}
121121
122122impl From < Utf8Error > for Error {
123123 #[ cold]
124- fn from ( err : Utf8Error ) -> Error {
125- Error :: Utf8Error ( err)
124+ fn from ( err : Utf8Error ) -> Self {
125+ Self :: Utf8Error ( err)
126126 }
127127}
128128
129129impl From < ValueReadError > for Error {
130130 #[ cold]
131- fn from ( err : ValueReadError ) -> Error {
131+ fn from ( err : ValueReadError ) -> Self {
132132 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) ,
136136 }
137137 }
138138}
139139
140140impl From < NumValueReadError > for Error {
141141 #[ cold]
142- fn from ( err : NumValueReadError ) -> Error {
142+ fn from ( err : NumValueReadError ) -> Self {
143143 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 ,
148148 }
149149 }
150150}
151151
152- impl < ' a > From < DecodeStringError < ' a > > for Error {
152+ impl From < DecodeStringError < ' _ > > for Error {
153153 #[ cold]
154- fn from ( err : DecodeStringError < ' _ > ) -> Error {
154+ fn from ( err : DecodeStringError < ' _ > ) -> Self {
155155 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 ( ) ) ,
161161 }
162162 }
163163}
164164
165165impl From < TryFromIntError > for Error {
166166 #[ cold]
167167 fn from ( _: TryFromIntError ) -> Self {
168- Error :: OutOfRange
168+ Self :: OutOfRange
169169 }
170170}
171171
@@ -246,7 +246,7 @@ impl<R: Read, C: SerializerConfig> Deserializer<R, C> {
246246 /// versions of `rmp-serde`.
247247 #[ inline]
248248 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 ;
250250 Deserializer {
251251 rd,
252252 is_human_readable : true ,
@@ -263,7 +263,7 @@ impl<R: Read, C: SerializerConfig> Deserializer<R, C> {
263263 /// representation.
264264 #[ inline]
265265 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 ;
267267 Deserializer {
268268 rd,
269269 is_human_readable : false ,
@@ -331,9 +331,7 @@ fn read_i128_marker<'de, R: ReadSlice<'de>>(marker: Marker, rd: &mut R) -> Resul
331331 let len = read_u8 ( & mut * rd) ?;
332332 read_128_buf ( rd, len) ?
333333 } ,
334- Marker :: FixArray ( len) => {
335- read_128_buf ( rd, len) ?
336- } ,
334+ Marker :: FixArray ( len) => read_128_buf ( rd, len) ?,
337335 marker => return Err ( Error :: TypeMismatch ( marker) ) ,
338336 } )
339337}
@@ -428,7 +426,7 @@ struct ExtDeserializer<'a, R, C> {
428426}
429427
430428impl < ' 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 {
432430 ExtDeserializer {
433431 rd : & mut d. rd ,
434432 _config : d. _config ,
@@ -551,7 +549,7 @@ impl<'de, R: ReadSlice<'de>, C: SerializerConfig> Deserializer<R, C> {
551549 Marker :: FixStr ( len) => Ok ( len. into ( ) ) ,
552550 Marker :: Str8 => read_u8 ( & mut self . rd ) . map ( u32:: from) ,
553551 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 ) ,
555553 _ => return Err ( Error :: TypeMismatch ( Marker :: Reserved ) ) ,
556554 } ?;
557555 read_str_data ( & mut self . rd , len, visitor)
@@ -598,7 +596,7 @@ impl<'de, R: ReadSlice<'de>, C: SerializerConfig> Deserializer<R, C> {
598596 let len = match marker {
599597 Marker :: Bin8 => read_u8 ( & mut self . rd ) . map ( u32:: from) ,
600598 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 ) ,
602600 _ => return Err ( Error :: TypeMismatch ( Marker :: Reserved ) ) ,
603601 } ?;
604602 match read_bin_data ( & mut self . rd , len) ? {
@@ -625,7 +623,7 @@ impl<'de, R: ReadSlice<'de>, C: SerializerConfig> Deserializer<R, C> {
625623 }
626624}
627625
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 > {
629627 type Error = Error ;
630628
631629 #[ inline( always) ]
@@ -821,7 +819,7 @@ struct SeqAccess<'a, R, C> {
821819
822820impl < ' a , R : ' a , C > SeqAccess < ' a , R , C > {
823821 #[ 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 {
825823 SeqAccess { de, left : len }
826824 }
827825}
@@ -854,7 +852,7 @@ struct MapAccess<'a, R, C> {
854852
855853impl < ' a , R : ' a , C > MapAccess < ' a , R , C > {
856854 #[ 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 {
858856 MapAccess { de, left : len }
859857 }
860858}
@@ -892,13 +890,13 @@ struct UnitVariantAccess<'a, R: 'a, C> {
892890}
893891
894892impl < ' 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 {
896894 UnitVariantAccess { de }
897895 }
898896}
899897
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 >
902900{
903901 type Error = Error ;
904902 type Variant = Self ;
@@ -962,12 +960,12 @@ struct VariantAccess<'a, R, C> {
962960}
963961
964962impl < ' 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 {
966964 VariantAccess { de }
967965 }
968966}
969967
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 > {
971969 type Error = Error ;
972970 type Variant = Self ;
973971
@@ -979,7 +977,7 @@ impl<'de, 'a, R: ReadSlice<'de>, C: SerializerConfig> de::EnumAccess<'de> for Va
979977 }
980978}
981979
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 > {
983981 type Error = Error ;
984982
985983 #[ inline]
@@ -1037,7 +1035,7 @@ pub struct ReadReader<R: Read> {
10371035impl < R : Read > ReadReader < R > {
10381036 #[ inline]
10391037 fn new ( rd : R ) -> Self {
1040- ReadReader {
1038+ Self {
10411039 rd,
10421040 buf : Vec :: with_capacity ( 128 ) ,
10431041 }
@@ -1079,7 +1077,7 @@ pub struct ReadRefReader<'a, R: ?Sized> {
10791077impl < ' a , T > ReadRefReader < ' a , T > {
10801078 /// Returns the part that hasn't been consumed yet
10811079 #[ must_use]
1082- pub fn remaining_slice ( & self ) -> & ' a [ u8 ] {
1080+ pub const fn remaining_slice ( & self ) -> & ' a [ u8 ] {
10831081 self . buf
10841082 }
10851083}
@@ -1094,7 +1092,7 @@ impl<'a, T: AsRef<[u8]> + ?Sized> ReadRefReader<'a, T> {
10941092 }
10951093}
10961094
1097- impl < ' a , T : AsRef < [ u8 ] > + ?Sized > Read for ReadRefReader < ' a , T > {
1095+ impl < T : AsRef < [ u8 ] > + ?Sized > Read for ReadRefReader < ' _ , T > {
10981096 #[ inline]
10991097 fn read ( & mut self , buf : & mut [ u8 ] ) -> Result < usize , io:: Error > {
11001098 self . buf . read ( buf)
0 commit comments