Louis Morgan 12 лет назад
Родитель
Сommit
b57d7d0d02
3 измененных файлов с 11 добавлено и 12 удалено
  1. 3 3
      src/parser.rs
  2. 1 1
      src/punycode.rs
  3. 7 8
      src/tests.rs

+ 3 - 3
src/parser.rs

@@ -413,7 +413,7 @@ pub fn parse_hostname<'a>(input: &'a str, parser: &UrlParser)
                     ']' => inside_square_brackets = false,
                     _ => (),
                 }
-                host_input.push_char(c)
+                host_input.push(c)
             }
         }
     }
@@ -463,7 +463,7 @@ fn parse_file_host<'a>(input: &'a str, parser: &UrlParser) -> ParseResult<(Host,
                 break
             },
             '\t' | '\n' | '\r' => try!(parser.parse_error(InvalidCharacter)),
-            _ => host_input.push_char(c)
+            _ => host_input.push(c)
         }
     }
     let host = if host_input.is_empty() {
@@ -638,7 +638,7 @@ pub fn parse_query<'a>(input: &'a str, context: Context, parser: &UrlParser)
             '\t' | '\n' | '\r' => try!(parser.parse_error(InvalidCharacter)),
             _ => {
                 try!(check_url_code_point(input, i, c, parser));
-                query.push_char(c);
+                query.push(c);
             }
         }
     }

+ 1 - 1
src/punycode.rs

@@ -209,7 +209,7 @@ fn value_to_digit(value: u32, output: &mut String) {
         26 ... 35 => value - 26 + 0x30,  // 0..9
         _ => fail!()
     };
-    unsafe { output.push_byte(code_point as u8) }
+    unsafe { output.as_mut_vec().push(code_point as u8) }
 }
 
 

+ 7 - 8
src/tests.rs

@@ -78,8 +78,7 @@ fn url_parsing() {
                 let host = host.serialize();
                 assert_eq!(host, expected_host)
                 assert_eq!(port, expected_port);
-                assert_eq!(Some("/".to_string().append(path.connect("/").as_slice())),
-                           expected_path);
+                assert_eq!(Some(format!("/{}", path.connect("/"))), expected_path);
             },
             NonRelativeSchemeData(scheme_data) => {
                 assert_eq!(Some(scheme_data), expected_path);
@@ -90,7 +89,7 @@ fn url_parsing() {
             },
         }
         fn opt_prepend(prefix: &str, opt_s: Option<String>) -> Option<String> {
-            opt_s.map(|s| prefix.to_string().append(s.as_slice()))
+            opt_s.map(|s| format!("{}{}", prefix, s))
         }
         assert_eq!(opt_prepend("?", query), expected_query);
         assert_eq!(opt_prepend("#", fragment), expected_fragment);
@@ -171,7 +170,7 @@ fn unescape(input: &str) -> String {
     loop {
         match chars.next() {
             None => return output,
-            Some(c) => output.push_char(
+            Some(c) => output.push(
                 if c == '\\' {
                     match chars.next().unwrap() {
                         '\\' => '\\',
@@ -182,10 +181,10 @@ fn unescape(input: &str) -> String {
                         'f' => '\x0C',
                         'u' => {
                             let mut hex = String::new();
-                            hex.push_char(chars.next().unwrap());
-                            hex.push_char(chars.next().unwrap());
-                            hex.push_char(chars.next().unwrap());
-                            hex.push_char(chars.next().unwrap());
+                            hex.push(chars.next().unwrap());
+                            hex.push(chars.next().unwrap());
+                            hex.push(chars.next().unwrap());
+                            hex.push(chars.next().unwrap());
                             u32::parse_bytes(hex.as_bytes(), 16)
                                 .and_then(char::from_u32).unwrap()
                         }