From 15c2c8620a74377e11502ab26d2edf7c5773cc25 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 23 Dec 2014 08:39:04 -0800 Subject: [PATCH] Update to rust master --- Cargo.toml | 3 +++ src/encoding.rs | 4 ++-- src/host.rs | 2 +- src/lib.rs | 6 +++--- src/percent_encoding.rs | 2 +- src/punycode.rs | 2 +- src/tests.rs | 2 +- 7 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6947a586..11b9e9fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,3 +19,6 @@ query_encoding = ["encoding"] version = "0.2" optional = true + +[dependencies] +rustc-serialize = "0.1" diff --git a/src/encoding.rs b/src/encoding.rs index b09c64f5..657b67c6 100644 --- a/src/encoding.rs +++ b/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]> { diff --git a/src/host.rs b/src/host.rs index c02d01c9..f109ccb5 100644 --- a/src/host.rs +++ b/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())) } } } diff --git a/src/lib.rs b/src/lib.rs index dc3ddd44..10d9015e 100644 --- a/src/lib.rs +++ b/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> serialize::Encodable for Url { +impl> rustc_serialize::Encodable for Url { fn encode(&self, encoder: &mut S) -> Result<(), E> { encoder.emit_str(self.to_string().as_slice()) } } -impl> serialize::Decodable for Url { +impl> rustc_serialize::Decodable for Url { fn decode(decoder: &mut D) -> Result { Url::parse(try!(decoder.read_str()).as_slice()).map_err(|error| { decoder.error(format!("URL parsing error: {}", error).as_slice()) diff --git a/src/percent_encoding.rs b/src/percent_encoding.rs index 7af053ce..0d7c3826 100644 --- a/src/percent_encoding.rs +++ b/src/percent_encoding.rs @@ -135,7 +135,7 @@ pub fn percent_decode(input: &[u8]) -> Vec { /// 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] diff --git a/src/punycode.rs b/src/punycode.rs index 9c009759..c0efee7f 100644 --- a/src/punycode.rs +++ b/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) { diff --git a/src/tests.rs b/src/tests.rs index 8e184817..7922d665 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -151,7 +151,7 @@ fn parse_test_data(input: &str) -> Vec { "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),