Skip to content

Commit

Permalink
Don’t reexport idna and percent_encoding in the url crate
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin committed Jul 15, 2019
1 parent 394e63a commit fe74a60
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 50 deletions.
49 changes: 2 additions & 47 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
}
}
}
}
}
7 changes: 4 additions & 3 deletions tests/unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit fe74a60

Please sign in to comment.