22 * License, v. 2.0. If a copy of the MPL was not distributed with this
33 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44
5+ use crate :: match_byte;
56use dtoa_short:: { self , Notation } ;
67use itoa;
78use std:: fmt:: { self , Write } ;
@@ -226,11 +227,15 @@ where
226227{
227228 let mut chunk_start = 0 ;
228229 for ( i, b) in value. bytes ( ) . enumerate ( ) {
229- let escaped = match b {
230+ let escaped = match_byte ! { b ,
230231 b'0' ..=b'9' | b'A' ..=b'Z' | b'a' ..=b'z' | b'_' | b'-' => continue ,
231- _ if !b. is_ascii ( ) => continue ,
232232 b'\0' => Some ( "\u{FFFD} " ) ,
233- _ => None ,
233+ b => {
234+ if !b. is_ascii( ) {
235+ continue ;
236+ }
237+ None
238+ } ,
234239 } ;
235240 dest. write_str ( & value[ chunk_start..i] ) ?;
236241 if let Some ( escaped) = escaped {
@@ -251,7 +256,7 @@ where
251256{
252257 let mut chunk_start = 0 ;
253258 for ( i, b) in value. bytes ( ) . enumerate ( ) {
254- let hex = match b {
259+ let hex = match_byte ! { b ,
255260 b'\0' ..=b' ' | b'\x7F' => true ,
256261 b'(' | b')' | b'"' | b'\'' | b'\\' => false ,
257262 _ => continue ,
@@ -304,7 +309,7 @@ where
304309{
305310 /// Wrap a text writer to create a `CssStringWriter`.
306311 pub fn new ( inner : & ' a mut W ) -> CssStringWriter < ' a , W > {
307- CssStringWriter { inner : inner }
312+ CssStringWriter { inner }
308313 }
309314}
310315
@@ -315,7 +320,7 @@ where
315320 fn write_str ( & mut self , s : & str ) -> fmt:: Result {
316321 let mut chunk_start = 0 ;
317322 for ( i, b) in s. bytes ( ) . enumerate ( ) {
318- let escaped = match b {
323+ let escaped = match_byte ! { b ,
319324 b'"' => Some ( "\\ \" " ) ,
320325 b'\\' => Some ( "\\ \\ " ) ,
321326 b'\0' => Some ( "\u{FFFD} " ) ,
0 commit comments