@@ -135,18 +135,6 @@ impl<S> Decode<'_, '_, S> for bool {
135135 }
136136}
137137
138- impl < S > Encode < S > for char {
139- fn encode ( self , w : & mut Buffer , s : & mut S ) {
140- ( self as u32 ) . encode ( w, s) ;
141- }
142- }
143-
144- impl < S > Decode < ' _ , ' _ , S > for char {
145- fn decode ( r : & mut & [ u8 ] , s : & mut S ) -> Self {
146- char:: from_u32 ( u32:: decode ( r, s) ) . unwrap ( )
147- }
148- }
149-
150138impl < S > Encode < S > for NonZero < u32 > {
151139 fn encode ( self , w : & mut Buffer , s : & mut S ) {
152140 self . get ( ) . encode ( w, s) ;
@@ -174,31 +162,20 @@ impl<'a, S, A: for<'s> Decode<'a, 's, S>, B: for<'s> Decode<'a, 's, S>> Decode<'
174162 }
175163}
176164
177- impl < S > Encode < S > for & [ u8 ] {
165+ impl < S > Encode < S > for & str {
178166 fn encode ( self , w : & mut Buffer , s : & mut S ) {
179- self . len ( ) . encode ( w, s) ;
180- w. write_all ( self ) . unwrap ( ) ;
167+ let bytes = self . as_bytes ( ) ;
168+ bytes. len ( ) . encode ( w, s) ;
169+ w. write_all ( bytes) . unwrap ( ) ;
181170 }
182171}
183172
184- impl < ' a , S > Decode < ' a , ' _ , S > for & ' a [ u8 ] {
173+ impl < ' a , S > Decode < ' a , ' _ , S > for & ' a str {
185174 fn decode ( r : & mut & ' a [ u8 ] , s : & mut S ) -> Self {
186175 let len = usize:: decode ( r, s) ;
187176 let xs = & r[ ..len] ;
188177 * r = & r[ len..] ;
189- xs
190- }
191- }
192-
193- impl < S > Encode < S > for & str {
194- fn encode ( self , w : & mut Buffer , s : & mut S ) {
195- self . as_bytes ( ) . encode ( w, s) ;
196- }
197- }
198-
199- impl < ' a , S > Decode < ' a , ' _ , S > for & ' a str {
200- fn decode ( r : & mut & ' a [ u8 ] , s : & mut S ) -> Self {
201- str:: from_utf8 ( <& [ u8 ] >:: decode ( r, s) ) . unwrap ( )
178+ str:: from_utf8 ( xs) . unwrap ( )
202179 }
203180}
204181
0 commit comments