Преглед изворни кода

Add an arbitrary ordering to `Url`. Fix #114.

Simon Sapin пре 11 година
родитељ
комит
6dbd743189
3 измењених фајлова са 7 додато и 7 уклоњено
  1. 1 1
      Cargo.toml
  2. 2 2
      src/host.rs
  3. 4 4
      src/lib.rs

+ 1 - 1
Cargo.toml

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

+ 2 - 2
src/host.rs

@@ -14,7 +14,7 @@ use percent_encoding::{from_hex, percent_decode};
 
 
 /// The host name of an URL.
-#[derive(PartialEq, Eq, Clone, Debug, Hash)]
+#[derive(PartialEq, Eq, Clone, Debug, Hash, PartialOrd, Ord)]
 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, Debug, Hash)]
+#[derive(Clone, Eq, PartialEq, Copy, Debug, Hash, PartialOrd, Ord)]
 pub struct Ipv6Address {
     pub pieces: [u16; 8]
 }

+ 4 - 4
src/lib.rs

@@ -149,7 +149,7 @@ mod tests;
 
 
 /// The parsed representation of an absolute URL.
-#[derive(PartialEq, Eq, Clone, Debug, Hash)]
+#[derive(PartialEq, Eq, Clone, Debug, Hash, PartialOrd, Ord)]
 pub struct Url {
     /// The scheme (a.k.a. protocol) of the URL, in ASCII lower case.
     pub scheme: String,
@@ -180,7 +180,7 @@ pub struct Url {
 }
 
 /// The components of the URL whose representation depends on where the scheme is *relative*.
-#[derive(PartialEq, Eq, Clone, Debug, Hash)]
+#[derive(PartialEq, Eq, Clone, Debug, Hash, PartialOrd, Ord)]
 pub enum SchemeData {
     /// Components for URLs in a *relative* scheme such as HTTP.
     Relative(RelativeSchemeData),
@@ -194,7 +194,7 @@ pub enum SchemeData {
 }
 
 /// Components for URLs in a *relative* scheme such as HTTP.
-#[derive(PartialEq, Eq, Clone, Debug, Hash)]
+#[derive(PartialEq, Eq, Clone, Debug, Hash, PartialOrd, Ord)]
 pub struct RelativeSchemeData {
     /// The username of the URL, as a possibly empty, percent-encoded string.
     ///
@@ -399,7 +399,7 @@ impl<'a> UrlParser<'a> {
 
 
 /// Determines the behavior of the URL parser for a given scheme.
-#[derive(PartialEq, Eq, Copy, Debug, Clone, Hash)]
+#[derive(PartialEq, Eq, Copy, Debug, Clone, Hash, PartialOrd, Ord)]
 pub enum SchemeType {
     /// Indicate that the scheme is *non-relative*.
     ///