Explorar o código

Don’t reexport idna and percent_encoding in the url crate

Simon Sapin %!s(int64=7) %!d(string=hai) anos
pai
achega
fe74a60bd0
Modificáronse 2 ficheiros con 6 adicións e 50 borrados
  1. 2 47
      src/lib.rs
  2. 4 3
      tests/unit.rs

+ 2 - 47
src/lib.rs

@@ -109,12 +109,11 @@ assert_eq!(css_url.as_str(), "http://servo.github.io/rust-url/main.css");
 
 #[macro_use]
 extern crate matches;
+extern crate idna;
 #[cfg(feature = "serde")]
 extern crate serde;
-
-pub extern crate idna;
 #[macro_use]
-pub extern crate percent_encoding;
+extern crate percent_encoding;
 
 use encoding::EncodingOverride;
 use host::HostInternal;
@@ -2538,47 +2537,3 @@ impl<'a> Drop for UrlQuery<'a> {
         }
     }
 }
-
-/// Define a new struct
-/// that implements the [`EncodeSet`](percent_encoding/trait.EncodeSet.html) trait,
-/// for use in [`percent_decode()`](percent_encoding/fn.percent_encode.html)
-/// and related functions.
-///
-/// Parameters are characters to include in the set in addition to those of the base set.
-/// See [encode sets specification](http://url.spec.whatwg.org/#simple-encode-set).
-///
-/// Example
-/// =======
-///
-/// ```rust
-/// #[macro_use] extern crate url;
-/// use url::percent_encoding::{utf8_percent_encode, SIMPLE_ENCODE_SET};
-/// define_encode_set! {
-///     /// This encode set is used in the URL parser for query strings.
-///     pub QUERY_ENCODE_SET = [SIMPLE_ENCODE_SET] | {' ', '"', '#', '<', '>'}
-/// }
-/// # fn main() {
-/// assert_eq!(utf8_percent_encode("foo bar", QUERY_ENCODE_SET).collect::<String>(), "foo%20bar");
-/// # }
-/// ```
-#[macro_export]
-macro_rules! define_encode_set {
-    ($(#[$attr: meta])* pub $name: ident = [$base_set: expr] | {$($ch: pat),*}) => {
-        $(#[$attr])*
-        #[derive(Copy, Clone)]
-        #[allow(non_camel_case_types)]
-        pub struct $name;
-
-        impl $crate::percent_encoding::EncodeSet for $name {
-            #[inline]
-            fn contains(&self, byte: u8) -> bool {
-                match byte as char {
-                    $(
-                        $ch => true,
-                    )*
-                    _ => $base_set.contains(byte)
-                }
-            }
-        }
-    }
-}

+ 4 - 3
tests/unit.rs

@@ -8,8 +8,9 @@
 
 //! Unit tests
 
-#[macro_use]
 extern crate url;
+#[macro_use]
+extern crate percent_encoding;
 
 use std::borrow::Cow;
 use std::cell::{Cell, RefCell};
@@ -468,7 +469,7 @@ fn test_leading_dots() {
 // inside both a module and a function
 #[test]
 fn define_encode_set_scopes() {
-    use url::percent_encoding::{utf8_percent_encode, SIMPLE_ENCODE_SET};
+    use percent_encoding::{utf8_percent_encode, SIMPLE_ENCODE_SET};
 
     define_encode_set! {
         /// This encode set is used in the URL parser for query strings.
@@ -481,7 +482,7 @@ fn define_encode_set_scopes() {
     );
 
     mod m {
-        use url::percent_encoding::{utf8_percent_encode, SIMPLE_ENCODE_SET};
+        use percent_encoding::{utf8_percent_encode, SIMPLE_ENCODE_SET};
 
         define_encode_set! {
             /// This encode set is used in the URL parser for query strings.