6
6
extern crate test;
7
7
8
8
use encoding_rs;
9
- use std:: borrow:: Cow :: { self , Borrowed } ;
10
9
use rustc_serialize:: json:: { self , Json , ToJson } ;
11
10
12
11
#[ cfg( feature = "bench" ) ]
@@ -17,7 +16,7 @@ use super::{Parser, Delimiter, Token, NumericValue, PercentageValue, SourceLocat
17
16
AtRuleType , AtRuleParser , QualifiedRuleParser , ParserInput ,
18
17
parse_one_declaration, parse_one_rule, parse_important,
19
18
stylesheet_encoding, EncodingSupport ,
20
- TokenSerializationType ,
19
+ TokenSerializationType , CompactCowStr ,
21
20
Color , RGBA , parse_nth, UnicodeRange , ToCss } ;
22
21
23
22
macro_rules! JArray {
@@ -290,12 +289,12 @@ fn unquoted_url_escaping() {
290
289
)\
291
290
") ;
292
291
let mut input = ParserInput :: new ( & serialized) ;
293
- assert_eq ! ( Parser :: new( & mut input) . next( ) , Ok ( token) )
292
+ assert_eq ! ( Parser :: new( & mut input) . next( ) , Ok ( token) ) ;
294
293
}
295
294
296
295
#[ test]
297
296
fn test_expect_url ( ) {
298
- fn parse < ' a > ( s : & mut ParserInput < ' a > ) -> Result < Cow < ' a , str > , BasicParseError < ' a > > {
297
+ fn parse < ' a > ( s : & mut ParserInput < ' a > ) -> Result < CompactCowStr < ' a > , BasicParseError < ' a > > {
299
298
Parser :: new ( s) . expect_url ( )
300
299
}
301
300
let mut input = ParserInput :: new ( "url()" ) ;
@@ -453,15 +452,15 @@ fn line_numbers() {
453
452
let mut input = ParserInput :: new ( "foo bar\n baz\r \n \n \" a\\ \r \n b\" " ) ;
454
453
let mut input = Parser :: new ( & mut input) ;
455
454
assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 1 , column: 1 } ) ;
456
- assert_eq ! ( input. next_including_whitespace( ) , Ok ( Token :: Ident ( Borrowed ( "foo" ) ) ) ) ;
455
+ assert_eq ! ( input. next_including_whitespace( ) , Ok ( Token :: Ident ( "foo" . into ( ) ) ) ) ;
457
456
assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 1 , column: 4 } ) ;
458
457
assert_eq ! ( input. next_including_whitespace( ) , Ok ( Token :: WhiteSpace ( " " ) ) ) ;
459
458
assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 1 , column: 5 } ) ;
460
- assert_eq ! ( input. next_including_whitespace( ) , Ok ( Token :: Ident ( Borrowed ( "bar" ) ) ) ) ;
459
+ assert_eq ! ( input. next_including_whitespace( ) , Ok ( Token :: Ident ( "bar" . into ( ) ) ) ) ;
461
460
assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 1 , column: 8 } ) ;
462
461
assert_eq ! ( input. next_including_whitespace( ) , Ok ( Token :: WhiteSpace ( "\n " ) ) ) ;
463
462
assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 2 , column: 1 } ) ;
464
- assert_eq ! ( input. next_including_whitespace( ) , Ok ( Token :: Ident ( Borrowed ( "baz" ) ) ) ) ;
463
+ assert_eq ! ( input. next_including_whitespace( ) , Ok ( Token :: Ident ( "baz" . into ( ) ) ) ) ;
465
464
assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 2 , column: 4 } ) ;
466
465
let position = input. position ( ) ;
467
466
@@ -470,7 +469,7 @@ fn line_numbers() {
470
469
471
470
assert_eq ! ( input. source_location( position) , SourceLocation { line: 2 , column: 4 } ) ;
472
471
473
- assert_eq ! ( input. next_including_whitespace( ) , Ok ( Token :: QuotedString ( Borrowed ( "ab" ) ) ) ) ;
472
+ assert_eq ! ( input. next_including_whitespace( ) , Ok ( Token :: QuotedString ( "ab" . into ( ) ) ) ) ;
474
473
assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 5 , column: 3 } ) ;
475
474
assert ! ( input. next_including_whitespace( ) . is_err( ) ) ;
476
475
}
@@ -679,7 +678,7 @@ impl<'i> DeclarationParser<'i> for JsonParser {
679
678
type Declaration = Json ;
680
679
type Error = ( ) ;
681
680
682
- fn parse_value < ' t > ( & mut self , name : Cow < ' i , str > , input : & mut Parser < ' i , ' t > )
681
+ fn parse_value < ' t > ( & mut self , name : CompactCowStr < ' i > , input : & mut Parser < ' i , ' t > )
683
682
-> Result < Json , ParseError < ' i , ( ) > > {
684
683
let mut value = vec ! [ ] ;
685
684
let mut important = false ;
@@ -720,7 +719,7 @@ impl<'i> AtRuleParser<'i> for JsonParser {
720
719
type AtRule = Json ;
721
720
type Error = ( ) ;
722
721
723
- fn parse_prelude < ' t > ( & mut self , name : Cow < ' i , str > , input : & mut Parser < ' i , ' t > )
722
+ fn parse_prelude < ' t > ( & mut self , name : CompactCowStr < ' i > , input : & mut Parser < ' i , ' t > )
724
723
-> Result < AtRuleType < Vec < Json > , Json > , ParseError < ' i , ( ) > > {
725
724
Ok ( AtRuleType :: OptionalBlock ( vec ! [
726
725
"at-rule" . to_json( ) ,
0 commit comments