Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upmove percent_encoding to its own crate #347
Conversation
|
Good stuff, few comments. |
| define_encode_set! { | ||
| /// This encode set is used in the URL parser for query strings. | ||
| pub QUERY_ENCODE_SET = [::url::percent_encoding::SIMPLE_ENCODE_SET] | {' ', '"', '#', '<', '>'} | ||
| } |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| /// # } | ||
| /// ``` | ||
| #[macro_export] | ||
| macro_rules! define_encode_set { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
SimonSapin
May 30, 2017
Member
IIRC the only way on current stable Rust is pub use some_crate::*;, which of course also re-exports other things.
This comment has been minimized.
This comment has been minimized.
seanmonstar
May 30, 2017
Author
Contributor
There's #[macro_reexport], which is unstable, and there's a the glob trick, which I'm still not certain is on purpose, but still, it re-exports too many things, so duplicating the macro seems required...
This comment has been minimized.
This comment has been minimized.
seanmonstar
Jun 8, 2017
Author
Contributor
@nox you said in IRC you prefer the glob trick. To reiterate, that requires a pub use percent_encoding::* inside the url root. That would suddenly make all the things normally in that module/crate pollute the url namespace. Suddenly there is url::SIMPLE_ENCODE_SET, besides url::percent_encoding::SIMPLE_ENCODE_SET and friends.
This comment has been minimized.
This comment has been minimized.
nox
Jun 8, 2017
Member
Can't you just put the macro in a submodule of percent_encoding and glob import that module from both percent_encoding and url?
This comment has been minimized.
This comment has been minimized.
seanmonstar
Jun 8, 2017
Author
Contributor
That's possible, but puts another public (useless) module in the percent_encoding crate. Of all the possible options, I find just redefining the macro in url to be the best.
This comment has been minimized.
This comment has been minimized.
nox
Jun 8, 2017
Member
Given both crates are in the same repository, IMO it is better to just make a #[doc(hidden)] module and avoid the duplication of the macro, but I'll let @SimonSapin the final say.
This comment has been minimized.
This comment has been minimized.
seanmonstar
Jun 8, 2017
Author
Contributor
When macros 2.0 arrive (already major pieces in nightly!), they can be named explicit, so it could eventually just become in url pub use percent_encoding::define_encode_set;.
This comment has been minimized.
This comment has been minimized.
nox
Jun 8, 2017
Member
Unfortunately I don't think these two crates can really afford to rely on hot new stuff, given how central it is to the ecosystem.
This comment has been minimized.
This comment has been minimized.
seanmonstar
Jun 8, 2017
Author
Contributor
We can cross that bridge when we get there, but this crate has already made upgrades to 1.15, and other than using the newest the day after, it seems to be fine to upgrade to newer version.
| @@ -0,0 +1,21 @@ | |||
| [package] | |||
| name = "percent_encode" | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
nox
May 30, 2017
Member
11:10 <•SimonSapin> nox: if we’re splitting hairs, I think "encoding" is the general mechanism and the two specific (opposite) operations are "encode" and "decode"
Let's name it percent_encoding.
I’m kind of splitting hairs, but I’d prefer |
|
Renamed to |
|
@SimonSapin or @nox, r? |
|
|
Move percent encoding to its own crate This is a rebase of #347 with some additional changes. Original work by @seanmonstar. Fixes #347. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-url/362) <!-- Reviewable:end -->
|
Landed in #362. Thanks! |
seanmonstar commentedMay 22, 2017
•
edited by larsbergstrom
percent_encode, but I could update it to bepercent_encodingif preferred.define_encode_setduplicated, to maintain backwards compatibility forurl.url, and so it can't make API breaking changes easily without affectingurl.This change is