-
-
Notifications
You must be signed in to change notification settings - Fork 362
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
feat(terminal): add Terminal::try_draw() method #1209
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1209 +/- ##
======================================
Coverage 94.4% 94.4%
======================================
Files 62 62
Lines 14941 15056 +115
======================================
+ Hits 14110 14225 +115
Misses 831 831 ☔ View full report in Codecov by Sentry. |
This makes it easier to write fallible rendering methods which can use the `?` operator
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.
Cool idea! LGTM! Curious what other people think.
|
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.
This simplifies the rendering but I'm not sure how useful it actually might be. Ideally the same Render Widget or whatever its named trait should exist here too I think? That would reduce the differences. Especially as a context is of interest anyway and Frame would reduce the need for the context too.
And the current trait doesn't allow for a Result currently either? Not sure what the ideal way would be.
I regularly find myself using methods which return results and having to throw away the possible errors inside of the draw method by either crashing or ignoring them. This would make it possible to add more context to the errors (using anyhow / eyre), and have the app more gracefully crash. This is a first point in making some of these future things more useful. We don't need to solve the entire problem, but this is a piece that is fine and necessary on its own. |
This makes it easier to write fallible rendering methods that can use the `?` operator ```rust terminal.try_draw(|frame| { some_method_that_can_fail()?; another_faillible_method()?; Ok(()) })?; ```
This makes it easier to write fallible rendering methods that can use the
?
operator