Răsfoiți Sursa

Upgrade to rustc 1.0.0-dev (a9be50e28 2015-01-09 19:44:50 +0000)

Simon Sapin 11 ani în urmă
părinte
comite
47da1ddbbb
7 a modificat fișierele cu 33 adăugiri și 28 ștergeri
  1. 1 1
      Cargo.toml
  2. 5 5
      src/format.rs
  3. 5 5
      src/host.rs
  4. 10 10
      src/lib.rs
  5. 10 5
      src/parser.rs
  6. 1 1
      src/punycode.rs
  7. 1 1
      src/tests.rs

+ 1 - 1
Cargo.toml

@@ -1,7 +1,7 @@
 [package]
 
 name = "url"
-version = "0.2.14"
+version = "0.2.15"
 authors = [ "Simon Sapin <simon.sapin@exyr.org>" ]
 
 description = "URL parser for Rust"

+ 5 - 5
src/format.rs

@@ -10,9 +10,9 @@
 //!
 //! These formatters can be used to coerce various URL parts into strings.
 //!
-//! You can use `<formatter>.to_string()`, as the formatters implement `Show`.
+//! You can use `<formatter>.to_string()`, as the formatters implement `fmt::String`.
 
-use std::fmt::{self, Show, Formatter};
+use std::fmt::{self, Formatter};
 use super::Url;
 
 /// Formatter and serializer for URL path data.
@@ -21,7 +21,7 @@ pub struct PathFormatter<'a, T:'a> {
     pub path: &'a [T]
 }
 
-impl<'a, T: Str + Show> Show for PathFormatter<'a, T> {
+impl<'a, T: Str + fmt::String> fmt::String for PathFormatter<'a, T> {
     fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
         if self.path.is_empty() {
             formatter.write_str("/")
@@ -47,7 +47,7 @@ pub struct UserInfoFormatter<'a> {
     pub password: Option<&'a str>
 }
 
-impl<'a> Show for UserInfoFormatter<'a> {
+impl<'a> fmt::String for UserInfoFormatter<'a> {
     fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
         if !self.username.is_empty() || self.password.is_some() {
             try!(formatter.write_str(self.username));
@@ -70,7 +70,7 @@ pub struct UrlNoFragmentFormatter<'a> {
     pub url: &'a Url
 }
 
-impl<'a> Show for UrlNoFragmentFormatter<'a> {
+impl<'a> fmt::String for UrlNoFragmentFormatter<'a> {
     fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
         try!(formatter.write_str(self.url.scheme.as_slice()));
         try!(formatter.write_str(":"));

+ 5 - 5
src/host.rs

@@ -8,13 +8,13 @@
 
 use std::ascii::{AsciiExt, OwnedAsciiExt};
 use std::cmp;
-use std::fmt::{self, Formatter, Show};
+use std::fmt::{self, Formatter};
 use parser::{ParseResult, ParseError};
 use percent_encoding::{from_hex, percent_decode};
 
 
 /// The host name of an URL.
-#[derive(PartialEq, Eq, Clone)]
+#[derive(PartialEq, Eq, Clone, Show)]
 pub enum Host {
     /// A (DNS) domain name or an IPv4 address.
     ///
@@ -30,7 +30,7 @@ pub enum Host {
 
 
 /// A 128 bit IPv6 address
-#[derive(Clone, Eq, PartialEq, Copy)]
+#[derive(Clone, Eq, PartialEq, Copy, Show)]
 pub struct Ipv6Address {
     pub pieces: [u16; 8]
 }
@@ -77,7 +77,7 @@ impl Host {
 }
 
 
-impl Show for Host {
+impl fmt::String for Host {
     fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
         match *self {
             Host::Domain(ref domain) => domain.fmt(formatter),
@@ -218,7 +218,7 @@ impl Ipv6Address {
 }
 
 
-impl Show for Ipv6Address {
+impl fmt::String for Ipv6Address {
     fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
         let (compress_start, compress_end) = longest_zero_sequence(&self.pieces);
         let mut i = 0;

+ 10 - 10
src/lib.rs

@@ -121,7 +121,7 @@ assert!(css_url.serialize() == "http://servo.github.io/rust-url/main.css".to_str
 
 extern crate "rustc-serialize" as rustc_serialize;
 
-use std::fmt::{self, Formatter, Show};
+use std::fmt::{self, Formatter};
 use std::hash;
 use std::path;
 
@@ -153,7 +153,7 @@ mod tests;
 
 
 /// The parsed representation of an absolute URL.
-#[derive(PartialEq, Eq, Clone)]
+#[derive(PartialEq, Eq, Clone, Show)]
 pub struct Url {
     /// The scheme (a.k.a. protocol) of the URL, in ASCII lower case.
     pub scheme: String,
@@ -184,7 +184,7 @@ pub struct Url {
 }
 
 /// The components of the URL whose representation depends on where the scheme is *relative*.
-#[derive(PartialEq, Eq, Clone)]
+#[derive(PartialEq, Eq, Clone, Show)]
 pub enum SchemeData {
     /// Components for URLs in a *relative* scheme such as HTTP.
     Relative(RelativeSchemeData),
@@ -198,7 +198,7 @@ pub enum SchemeData {
 }
 
 /// Components for URLs in a *relative* scheme such as HTTP.
-#[derive(PartialEq, Eq, Clone)]
+#[derive(PartialEq, Eq, Clone, Show)]
 pub struct RelativeSchemeData {
     /// The username of the URL, as a possibly empty, pecent-encoded string.
     ///
@@ -237,8 +237,8 @@ pub struct RelativeSchemeData {
     pub path: Vec<String>,
 }
 
-impl<S: hash::Writer> hash::Hash<S> for Url {
-    fn hash(&self, state: &mut S) {
+impl<H: hash::Hasher + hash::Writer> hash::Hash<H> for Url {
+    fn hash(&self, state: &mut H) {
         self.serialize().hash(state)
     }
 }
@@ -401,7 +401,7 @@ impl<'a> UrlParser<'a> {
 
 
 /// Determines the behavior of the URL parser for a given scheme.
-#[derive(PartialEq, Eq, Copy)]
+#[derive(PartialEq, Eq, Copy, Show)]
 pub enum SchemeType {
     /// Indicate that the scheme is *non-relative*.
     ///
@@ -764,7 +764,7 @@ impl rustc_serialize::Decodable for Url {
 }
 
 
-impl Show for Url {
+impl fmt::String for Url {
     fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
         try!(UrlNoFragmentFormatter{ url: self }.fmt(formatter));
         match self.fragment {
@@ -779,7 +779,7 @@ impl Show for Url {
 }
 
 
-impl Show for SchemeData {
+impl fmt::String for SchemeData {
     fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
         match *self {
             SchemeData::Relative(ref scheme_data) => scheme_data.fmt(formatter),
@@ -884,7 +884,7 @@ impl RelativeSchemeData {
 }
 
 
-impl Show for RelativeSchemeData {
+impl fmt::String for RelativeSchemeData {
     fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
         // Write the scheme-trailing double slashes.
         try!(formatter.write_str("//"));

+ 10 - 5
src/parser.rs

@@ -8,7 +8,7 @@
 
 use std::ascii::AsciiExt;
 use std::error::Error;
-use std::fmt::{self, Formatter, Show};
+use std::fmt::{self, Formatter};
 use std::str::CharRange;
 
 use super::{UrlParser, Url, SchemeData, RelativeSchemeData, Host, SchemeType};
@@ -18,9 +18,14 @@ use percent_encoding::{
 };
 
 
+/// Work around "error: unexpected token: `an interpolated tt`", whatever that means.
+macro_rules! _tt_as_expr_hack(
+    ($value:expr) => ($value)
+);
+
 macro_rules! is_match(
-    ($value:expr, $($pattern:pat)|+) => (
-        match $value { $($pattern)|+ => true, _ => false }
+    ($value:expr, $($pattern:tt)+) => (
+        _tt_as_expr_hack!( match $value { $($pattern)+ => true, _ => false })
     );
 );
 
@@ -31,7 +36,7 @@ pub type ParseResult<T> = Result<T, ParseError>;
 macro_rules! simple_enum_error {
     ($($name: ident => $description: expr,)+) => {
         /// Errors that can occur during parsing.
-        #[derive(PartialEq, Eq, Clone, Copy)]
+        #[derive(PartialEq, Eq, Clone, Copy, Show)]
         pub enum ParseError {
             $(
                 $name,
@@ -77,7 +82,7 @@ simple_enum_error! {
     CannotSetPathWithNonRelativeScheme => "cannot set path with non-relative scheme",
 }
 
-impl Show for ParseError {
+impl fmt::String for ParseError {
     fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
         self.description().fmt(fmt)
     }

+ 1 - 1
src/punycode.rs

@@ -261,7 +261,7 @@ mod tests {
                     _ => panic!(),
                 }
             },
-            other => panic!("{}", other)
+            other => panic!("{:?}", other)
         }
     }
 }

+ 1 - 1
src/tests.rs

@@ -60,7 +60,7 @@ fn url_parsing() {
                         if expected_failure {
                             continue
                         } else {
-                            panic!("{} != {}", a, b)
+                            panic!("{:?} != {:?}", a, b)
                         }
                     }
                 }