-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
Seems reasonable to me @rfcbot fcp merge |
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> { |
There was a problem hiding this comment.
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;
There was a problem hiding this comment.
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.
b0adb44
to
778d5f2
Compare
🔔 This is now entering its final comment period, as per the review above. 🔔 |
@bors: r+ |
📌 Commit 778d5f2 has been approved by |
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()`.
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()`.
Considering how impls exist for
String
and&str
, it makes sense to also add an impl forCow<str>
as well.This would allow converting
String::from_utf8_lossy
directly into aBox<Error>
orio::Error
without having to add an extrainto_ownd()
.