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

Derive Clone + Eq for std::string::FromUtf8Error #68738

Merged
merged 1 commit into from Feb 9, 2020

Conversation

@kennytm
Copy link
Member

kennytm commented Feb 1, 2020

Implement Clone and Eq for std::string::FromUtf8Error.

Both the inner Vec<u8> and std::str::Utf8Error are also Clone + Eq, so I don't see why we shouldn't derive them on FromUtf8Error as well.

(impl are insta-stable, requiring FCP from T-libs.)

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Feb 1, 2020

r? @sfackler

(rust_highfive has picked a reviewer for you, use r? to override)

@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented Feb 1, 2020

My only potential concern would be if we changed the implementation to track more information such that previously equal values became non-equal in the future. I think that would probably fall under expected breakage though?

@rfcbot fcp merge

@rfcbot

This comment has been minimized.

Copy link

rfcbot commented Feb 1, 2020

Team member @sfackler has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@dtolnay

This comment has been minimized.

Copy link
Member

dtolnay commented Feb 1, 2020

These seem fine but could you explain the use case that requires Clone and Eq so that we have a record when considering future cases? The ones for Utf8Error are 5 years old (#19741) and in that time I don't know of anyone having asked for them on FromUtf8Error.

@kennytm

This comment has been minimized.

Copy link
Member Author

kennytm commented Feb 2, 2020

@sfackler We could switch to manually-implemented PartialEq to keep the previous behavior, if the previous behavior does make more sense.

@dtolnay I wanted to encapsulate Result<String, FromUtf8Error> as a single "maybe-UTF-8-string" object, and also implement Clone on it (PartialEq can be manually implemented).

While this type is isomorphic to Result<String, (Vec<u8>, Utf8Error)> so we don't require FromUtf8Error: Clone, I see no reason we should not implement Clone + PartialEq + Eq on it.

@rfcbot

This comment has been minimized.

Copy link

rfcbot commented Feb 9, 2020

🔔 This is now entering its final comment period, as per the review above. 🔔

@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented Feb 9, 2020

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 9, 2020

📌 Commit 847d5b4 has been approved by sfackler

jonas-schievink added a commit to jonas-schievink/rust that referenced this pull request Feb 9, 2020
…8error, r=sfackler

Derive Clone + Eq for std::string::FromUtf8Error

Implement `Clone` and `Eq` for `std::string::FromUtf8Error`.

Both the inner `Vec<u8>` and `std::str::Utf8Error` are also `Clone + Eq`, so I don't see why we shouldn't derive them on `FromUtf8Error` as well.

(impl are insta-stable, requiring FCP from T-libs.)
bors added a commit that referenced this pull request Feb 9, 2020
Rollup of 5 pull requests

Successful merges:

 - #68738 (Derive Clone + Eq for std::string::FromUtf8Error)
 - #68742 (implement AsMut<str> for String)
 - #68881 (rustc_codegen_llvm: always set AlwaysPreserve on all debuginfo variables)
 - #68911 (Speed up the inherent impl overlap check)
 - #68913 (Pretty-print generic params and where clauses on associated types)

Failed merges:

r? @ghost
@bors bors merged commit 847d5b4 into rust-lang:master Feb 9, 2020
4 checks passed
4 checks passed
pr Build #20200201.28 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-7) Linux x86_64-gnu-llvm-7 succeeded
Details
pr (Linux x86_64-gnu-tools) Linux x86_64-gnu-tools succeeded
Details
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

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