66extern crate test;
77
88use encoding_rs;
9- use std:: borrow:: Cow :: { self , Borrowed } ;
109use rustc_serialize:: json:: { self , Json , ToJson } ;
1110
1211#[ cfg( feature = "bench" ) ]
@@ -17,7 +16,7 @@ use super::{Parser, Delimiter, Token, NumericValue, PercentageValue, SourceLocat
1716 AtRuleType , AtRuleParser , QualifiedRuleParser , ParserInput ,
1817 parse_one_declaration, parse_one_rule, parse_important,
1918 stylesheet_encoding, EncodingSupport ,
20- TokenSerializationType ,
19+ TokenSerializationType , CompactCowStr ,
2120 Color , RGBA , parse_nth, UnicodeRange , ToCss } ;
2221
2322macro_rules! JArray {
@@ -290,12 +289,12 @@ fn unquoted_url_escaping() {
290289 )\
291290 ") ;
292291 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) ) ;
294293}
295294
296295#[ test]
297296fn 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 > > {
299298 Parser :: new ( s) . expect_url ( )
300299 }
301300 let mut input = ParserInput :: new ( "url()" ) ;
@@ -453,15 +452,15 @@ fn line_numbers() {
453452 let mut input = ParserInput :: new ( "foo bar\n baz\r \n \n \" a\\ \r \n b\" " ) ;
454453 let mut input = Parser :: new ( & mut input) ;
455454 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 ( ) ) ) ) ;
457456 assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 1 , column: 4 } ) ;
458457 assert_eq ! ( input. next_including_whitespace( ) , Ok ( Token :: WhiteSpace ( " " ) ) ) ;
459458 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 ( ) ) ) ) ;
461460 assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 1 , column: 8 } ) ;
462461 assert_eq ! ( input. next_including_whitespace( ) , Ok ( Token :: WhiteSpace ( "\n " ) ) ) ;
463462 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 ( ) ) ) ) ;
465464 assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 2 , column: 4 } ) ;
466465 let position = input. position ( ) ;
467466
@@ -470,7 +469,7 @@ fn line_numbers() {
470469
471470 assert_eq ! ( input. source_location( position) , SourceLocation { line: 2 , column: 4 } ) ;
472471
473- assert_eq ! ( input. next_including_whitespace( ) , Ok ( Token :: QuotedString ( Borrowed ( "ab" ) ) ) ) ;
472+ assert_eq ! ( input. next_including_whitespace( ) , Ok ( Token :: QuotedString ( "ab" . into ( ) ) ) ) ;
474473 assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 5 , column: 3 } ) ;
475474 assert ! ( input. next_including_whitespace( ) . is_err( ) ) ;
476475}
@@ -679,7 +678,7 @@ impl<'i> DeclarationParser<'i> for JsonParser {
679678 type Declaration = Json ;
680679 type Error = ( ) ;
681680
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 > )
683682 -> Result < Json , ParseError < ' i , ( ) > > {
684683 let mut value = vec ! [ ] ;
685684 let mut important = false ;
@@ -720,7 +719,7 @@ impl<'i> AtRuleParser<'i> for JsonParser {
720719 type AtRule = Json ;
721720 type Error = ( ) ;
722721
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 > )
724723 -> Result < AtRuleType < Vec < Json > , Json > , ParseError < ' i , ( ) > > {
725724 Ok ( AtRuleType :: OptionalBlock ( vec ! [
726725 "at-rule" . to_json( ) ,
0 commit comments