2
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
3
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
4
5
+ use crate :: match_byte;
5
6
use dtoa_short:: { self , Notation } ;
6
7
use itoa;
7
8
use std:: fmt:: { self , Write } ;
@@ -226,11 +227,15 @@ where
226
227
{
227
228
let mut chunk_start = 0 ;
228
229
for ( i, b) in value. bytes ( ) . enumerate ( ) {
229
- let escaped = match b {
230
+ let escaped = match_byte ! { b ,
230
231
b'0' ..=b'9' | b'A' ..=b'Z' | b'a' ..=b'z' | b'_' | b'-' => continue ,
231
- _ if !b. is_ascii ( ) => continue ,
232
232
b'\0' => Some ( "\u{FFFD} " ) ,
233
- _ => None ,
233
+ b => {
234
+ if !b. is_ascii( ) {
235
+ continue ;
236
+ }
237
+ None
238
+ } ,
234
239
} ;
235
240
dest. write_str ( & value[ chunk_start..i] ) ?;
236
241
if let Some ( escaped) = escaped {
@@ -251,7 +256,7 @@ where
251
256
{
252
257
let mut chunk_start = 0 ;
253
258
for ( i, b) in value. bytes ( ) . enumerate ( ) {
254
- let hex = match b {
259
+ let hex = match_byte ! { b ,
255
260
b'\0' ..=b' ' | b'\x7F' => true ,
256
261
b'(' | b')' | b'"' | b'\'' | b'\\' => false ,
257
262
_ => continue ,
@@ -304,7 +309,7 @@ where
304
309
{
305
310
/// Wrap a text writer to create a `CssStringWriter`.
306
311
pub fn new ( inner : & ' a mut W ) -> CssStringWriter < ' a , W > {
307
- CssStringWriter { inner : inner }
312
+ CssStringWriter { inner }
308
313
}
309
314
}
310
315
@@ -315,7 +320,7 @@ where
315
320
fn write_str ( & mut self , s : & str ) -> fmt:: Result {
316
321
let mut chunk_start = 0 ;
317
322
for ( i, b) in s. bytes ( ) . enumerate ( ) {
318
- let escaped = match b {
323
+ let escaped = match_byte ! { b ,
319
324
b'"' => Some ( "\\ \" " ) ,
320
325
b'\\' => Some ( "\\ \\ " ) ,
321
326
b'\0' => Some ( "\u{FFFD} " ) ,
0 commit comments