Alex Crichton 11 лет назад
Родитель
Сommit
15c2c8620a
7 измененных файлов с 12 добавлено и 9 удалено
  1. 3 0
      Cargo.toml
  2. 2 2
      src/encoding.rs
  3. 1 1
      src/host.rs
  4. 3 3
      src/lib.rs
  5. 1 1
      src/percent_encoding.rs
  6. 1 1
      src/punycode.rs
  7. 1 1
      src/tests.rs

+ 3 - 0
Cargo.toml

@@ -19,3 +19,6 @@ query_encoding = ["encoding"]
 
 version = "0.2"
 optional = true
+
+[dependencies]
+rustc-serialize = "0.1"

+ 2 - 2
src/encoding.rs

@@ -54,7 +54,7 @@ impl EncodingOverride {
     pub fn decode(&self, input: &[u8]) -> String {
         match self.encoding {
             Some(encoding) => encoding.decode(input, DecoderTrap::Replace).unwrap(),
-            None => String::from_utf8_lossy(input).into_string(),
+            None => String::from_utf8_lossy(input).to_string(),
         }
     }
 
@@ -87,7 +87,7 @@ impl EncodingOverride {
     }
 
     pub fn decode(&self, input: &[u8]) -> String {
-        String::from_utf8_lossy(input).into_string()
+        String::from_utf8_lossy(input).into_owned()
     }
 
     pub fn encode<'a>(&self, input: &'a str) -> Cow<'a, Vec<u8>, [u8]> {

+ 1 - 1
src/host.rs

@@ -63,7 +63,7 @@ impl Host {
             ].as_slice()).is_some() {
                 Err(ParseError::InvalidDomainCharacter)
             } else {
-                Ok(Host::Domain(domain.into_string().into_ascii_lower()))
+                Ok(Host::Domain(domain.to_string().into_ascii_lower()))
             }
         }
     }

+ 3 - 3
src/lib.rs

@@ -121,7 +121,7 @@ assert!(css_url.serialize() == "http://servo.github.io/rust-url/main.css".to_str
 
 #![feature(macro_rules, default_type_params)]
 
-extern crate serialize;
+extern crate "rustc-serialize" as rustc_serialize;
 
 use std::fmt::{mod, Formatter, Show};
 use std::hash;
@@ -750,14 +750,14 @@ impl Url {
 }
 
 
-impl<E, S: serialize::Encoder<E>> serialize::Encodable<S, E> for Url {
+impl<E, S: rustc_serialize::Encoder<E>> rustc_serialize::Encodable<S, E> for Url {
     fn encode(&self, encoder: &mut S) -> Result<(), E> {
         encoder.emit_str(self.to_string().as_slice())
     }
 }
 
 
-impl<E, D: serialize::Decoder<E>> serialize::Decodable<D, E> for Url {
+impl<E, D: rustc_serialize::Decoder<E>> rustc_serialize::Decodable<D, E> for Url {
     fn decode(decoder: &mut D) -> Result<Url, E> {
         Url::parse(try!(decoder.read_str()).as_slice()).map_err(|error| {
             decoder.error(format!("URL parsing error: {}", error).as_slice())

+ 1 - 1
src/percent_encoding.rs

@@ -135,7 +135,7 @@ pub fn percent_decode(input: &[u8]) -> Vec<u8> {
 /// will be replaced � U+FFFD, the replacement character.
 #[inline]
 pub fn lossy_utf8_percent_decode(input: &[u8]) -> String {
-    String::from_utf8_lossy(percent_decode(input).as_slice()).into_string()
+    String::from_utf8_lossy(percent_decode(input).as_slice()).to_string()
 }
 
 #[inline]

+ 1 - 1
src/punycode.rs

@@ -215,7 +215,7 @@ fn value_to_digit(value: u32, output: &mut String) {
 #[cfg(test)]
 mod tests {
     use super::{decode, encode_str};
-    use serialize::json::{from_str, Json, Object};
+    use rustc_serialize::json::{from_str, Json, Object};
 
     fn one_test(description: &str, decoded: &str, encoded: &str) {
         match decode(encoded) {

+ 1 - 1
src/tests.rs

@@ -151,7 +151,7 @@ fn parse_test_data(input: &str) -> Vec<Test> {
                 "u" => test.username = value,
                 "pass" => test.password = Some(value),
                 "h" => test.host = value,
-                "port" => test.port = Some(from_str(value.as_slice()).unwrap()),
+                "port" => test.port = Some(value.parse().unwrap()),
                 "p" => test.path = Some(value),
                 "q" => test.query = Some(value),
                 "f" => test.fragment = Some(value),