-
Notifications
You must be signed in to change notification settings - Fork 85
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
Allow conversion from Report
to Error
#1749
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov Report
@@ Coverage Diff @@
## main #1749 +/- ##
==========================================
+ Coverage 55.42% 55.46% +0.03%
==========================================
Files 223 224 +1
Lines 15096 15136 +40
Branches 378 378
==========================================
+ Hits 8367 8395 +28
- Misses 6724 6736 +12
Partials 5 5
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
impl<C> Error for ReportError<C> { | ||
#[cfg(nightly)] | ||
fn provide<'a>(&'a self, demand: &mut Demand<'a>) { | ||
self.0.frames().for_each(|frame| frame.provide(demand)); |
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.
Out of curiosity, any reason for choosing for_each
over for frame in self.frames()
?
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.
No specific reason. I used it here as it's only one line vs three lines.
@@ -464,7 +464,6 @@ | |||
)] | |||
|
|||
extern crate alloc; | |||
extern crate core; |
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.
I love how CLion always automatically adds this line...
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.
Looks good to me, just some minor non-blocking comments. I already noted this over private DMs, but with this change
#[test]
fn as_error_nest() {
let report = create_report();
let base = report.into_error();
let report = Report::new(base);
println!("{report:?}");
}
is possible. I think that is ok, as it does not break formatting and has quite the high barrier for creating it.
Thanks, @indietyp! |
🌟 What is the purpose of this PR?
It's currently hard to deal with
Report
when anError
is required. This PR adds conversions fromReport
toError
.🔗 Related links
🔍 What does this change?
Report::into_error
to convertimpl Error
Report::as_error
to return&impl Error
From
implementation ofReport
forBox<dyn Error>
(+Send
and/orSync
)📜 Does this require a change to the docs?
The changelog was changed to reflect these changes
🛡 What tests cover this?
Three new tests were added:
into_report
cannot be called onResult<T, Report<C>>
Report
toError
and ensure, that the provided values are still accessible