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

Add Cow<str> -> Box<Error> impls. #44466

Merged
merged 1 commit into from
Sep 18, 2017
Merged

Conversation

clarfonthey
Copy link
Contributor

@clarfonthey clarfonthey commented Sep 9, 2017

Considering how impls exist for String and &str, it makes sense to also add an impl for Cow<str> as well.

This would allow converting String::from_utf8_lossy directly into a Box<Error> or io::Error without having to add an extra into_ownd().

@rust-highfive
Copy link
Collaborator

r? @alexcrichton

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

@alexcrichton alexcrichton added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Sep 10, 2017
@alexcrichton
Copy link
Member

Seems reasonable to me

@rfcbot fcp merge

@rfcbot rfcbot added the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Sep 10, 2017
@rfcbot
Copy link

rfcbot commented Sep 10, 2017

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

No concerns currently listed.

Once these reviewers reach consensus, 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.

@@ -217,6 +217,20 @@ impl<'a> From<&'a str> for Box<Error> {
}
}

#[stable(feature = "cow_box_error", since = "1.22.0")]
impl<'a, 'b> From<Cow<'b, str>> for Box<Error + Send + Sync + 'a> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to import Cow.

[00:03:22] error[E0412]: cannot find type `Cow` in this scope
[00:03:22]    --> /checkout/src/libstd/error.rs:221:19
[00:03:22]     |
[00:03:22] 221 | impl<'a, 'b> From<Cow<'b, str>> for Box<Error + Send + Sync + 'a> {
[00:03:22]     |                   ^^^ not found in this scope
[00:03:22]     |
[00:03:22] help: possible candidate is found in another module, you can import it into scope
[00:03:22]     |
[00:03:22] 66  | use alloc::borrow::Cow;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was a silly error. Fixed.

@carols10cents carols10cents added the S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). label Sep 11, 2017
@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Sep 12, 2017
@rfcbot
Copy link

rfcbot commented Sep 12, 2017

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

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Sep 12, 2017

📌 Commit 778d5f2 has been approved by alexcrichton

@aidanhs aidanhs added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). labels Sep 13, 2017
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Sep 18, 2017
Add Cow<str> -> Box<Error> impls.

Considering how impls exist for `String` and `&str`, it makes sense to also add an impl for `Cow<str>` as well.

This would allow converting `String::from_utf8_lossy` directly into a `Box<Error>` or `io::Error` without having to add an extra `into_ownd()`.
bors added a commit that referenced this pull request Sep 18, 2017
Rollup of 10 pull requests

- Successful merges: #44364, #44466, #44537, #44640, #44651, #44657, #44661, #44668, #44671, #44675
- Failed merges:
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Sep 18, 2017
Add Cow<str> -> Box<Error> impls.

Considering how impls exist for `String` and `&str`, it makes sense to also add an impl for `Cow<str>` as well.

This would allow converting `String::from_utf8_lossy` directly into a `Box<Error>` or `io::Error` without having to add an extra `into_ownd()`.
bors added a commit that referenced this pull request Sep 18, 2017
Rollup of 11 pull requests

- Successful merges: #44364, #44466, #44537, #44548, #44640, #44651, #44657, #44661, #44668, #44671, #44675
- Failed merges:
@bors bors merged commit 778d5f2 into rust-lang:master Sep 18, 2017
@clarfonthey clarfonthey deleted the cow_error branch September 20, 2017 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants