Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Serialize and Deserialze for Host #272

Merged
merged 1 commit into from Jan 24, 2017

Conversation

@cbrewster
Copy link
Member

cbrewster commented Jan 23, 2017

This change is Reviewable

@cbrewster cbrewster force-pushed the cbrewster:host_serialization branch from 3c5fe48 to d7e7e24 Jan 23, 2017
@SimonSapin
Copy link
Member

SimonSapin commented Jan 23, 2017

Looks good! Just some minor details.


Reviewed 2 of 2 files at r1.
Review status: all files reviewed at latest revision, 4 unresolved discussions.


Cargo.toml, line 4 at r1 (raw file):

name = "url"
version = "1.3.1"

This PR introduces new functionality, so I think SemVer says the version number should be 1.4.0.


src/host.rs, line 61 at r1 (raw file):

#[cfg(feature="serde")]
impl ::serde::Serialize for Host {

Host<S=String> is generic (with a default). I think this impl should be impl<S: AsRef<str>> ::serde::Serialize for Host<S>. For example Host<&str> is used in Url::host.


src/host.rs, line 73 at r1 (raw file):

#[cfg(feature="serde")]
impl::serde::Deserialize for Host {

This is probably less important than for Serialize (since Self is used in an owned return value, and so can not contains &str), but while you’re at it please make this impl generic as well: impl<S: From<String>> ::serde::Deserialize for Host<S>.


src/host.rs, line 73 at r1 (raw file):

#[cfg(feature="serde")]
impl::serde::Deserialize for Host {

Nit: space before ::serde.


Comments from Reviewable

@asajeffrey
Copy link
Member

asajeffrey commented Jan 23, 2017

Review status: all files reviewed at latest revision, 4 unresolved discussions.


Cargo.toml, line 4 at r1 (raw file):

Previously, SimonSapin (Simon Sapin) wrote…

This PR introduces new functionality, so I think SemVer says the version number should be 1.4.0.

I think RFC 1105 allows this as a minor change: https://github.com/rust-lang/rfcs/blob/master/text/1105-api-evolution.md#minor-change-adding-new-public-items.


Comments from Reviewable

@SimonSapin
Copy link
Member

SimonSapin commented Jan 23, 2017

Review status: all files reviewed at latest revision, 4 unresolved discussions.


Cargo.toml, line 4 at r1 (raw file):

Previously, asajeffrey (Alan Jeffrey) wrote…

I think RFC 1105 allows this as a minor change: https://github.com/rust-lang/rfcs/blob/master/text/1105-api-evolution.md#minor-change-adding-new-public-items.

Yes, it’s not a breaking change. That would be version 2.0.0.

Cargo treats 1.3.1 and 1.4.0 the same, the difference is only for communicating to humans. (I’d be fine with just two components in the version number, but SemVer seems to be what the Rust ecosystem settled on.)


Comments from Reviewable

@cbrewster cbrewster force-pushed the cbrewster:host_serialization branch from d7e7e24 to fa6bfe0 Jan 24, 2017
@cbrewster
Copy link
Member Author

cbrewster commented Jan 24, 2017

Review status: 0 of 2 files reviewed at latest revision, 4 unresolved discussions.


Cargo.toml, line 4 at r1 (raw file):

Previously, SimonSapin (Simon Sapin) wrote…

Yes, it’s not a breaking change. That would be version 2.0.0.

Cargo treats 1.3.1 and 1.4.0 the same, the difference is only for communicating to humans. (I’d be fine with just two components in the version number, but SemVer seems to be what the Rust ecosystem settled on.)

Done.


src/host.rs, line 61 at r1 (raw file):

Previously, SimonSapin (Simon Sapin) wrote…

Host<S=String> is generic (with a default). I think this impl should be impl<S: AsRef<str>> ::serde::Serialize for Host<S>. For example Host<&str> is used in Url::host.

Done. I had to also add a Serialize bound.


src/host.rs, line 73 at r1 (raw file):

Previously, SimonSapin (Simon Sapin) wrote…

This is probably less important than for Serialize (since Self is used in an owned return value, and so can not contains &str), but while you’re at it please make this impl generic as well: impl<S: From<String>> ::serde::Deserialize for Host<S>.

Done. I had to also add a Deserialize bound.


src/host.rs, line 73 at r1 (raw file):

Previously, SimonSapin (Simon Sapin) wrote…

Nit: space before ::serde.

Done.


Comments from Reviewable

@SimonSapin
Copy link
Member

SimonSapin commented Jan 24, 2017

Reviewed 2 of 2 files at r2.
Review status: all files reviewed at latest revision, 3 unresolved discussions.


src/host.rs, line 61 at r1 (raw file):

Previously, cbrewster (Connor Brewster) wrote…

Done. I had to also add a Serialize bound.

I was thinking of serializing the result of as_ref(). I hadn’t thought of using a Serialize bound. Since the latter is more generic let’s keep it. But now the AsRef bound is unnecessary, so please remove it.


src/host.rs, line 73 at r1 (raw file):

Previously, cbrewster (Connor Brewster) wrote…

Done. I had to also add a Deserialize bound.

Same as above, please remove the From bound as it is unnecessary with the Deserialize one.


Comments from Reviewable

@cbrewster cbrewster force-pushed the cbrewster:host_serialization branch from fa6bfe0 to 2aaa190 Jan 24, 2017
@cbrewster
Copy link
Member Author

cbrewster commented Jan 24, 2017

Review status: 1 of 2 files reviewed at latest revision, 3 unresolved discussions.


src/host.rs, line 61 at r1 (raw file):

Previously, SimonSapin (Simon Sapin) wrote…

I was thinking of serializing the result of as_ref(). I hadn’t thought of using a Serialize bound. Since the latter is more generic let’s keep it. But now the AsRef bound is unnecessary, so please remove it.

Done.


src/host.rs, line 73 at r1 (raw file):

Previously, SimonSapin (Simon Sapin) wrote…

Same as above, please remove the From bound as it is unnecessary with the Deserialize one.

Done.


Comments from Reviewable

@SimonSapin
Copy link
Member

SimonSapin commented Jan 24, 2017

@bors-servo r+


Reviewed 1 of 1 files at r3.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


Comments from Reviewable

@bors-servo
Copy link
Contributor

bors-servo commented Jan 24, 2017

📌 Commit 2aaa190 has been approved by SimonSapin

@bors-servo
Copy link
Contributor

bors-servo commented Jan 24, 2017

Test exempted - status

@bors-servo bors-servo merged commit 2aaa190 into servo:master Jan 24, 2017
3 of 4 checks passed
3 of 4 checks passed
code-review/reviewable 1 discussion left (asajeffrey)
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test exempted
Details
bors-servo added a commit that referenced this pull request Jan 24, 2017
Implement Serialize and Deserialze for Host

<!-- 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/272)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.