Open joshka opened 2 weeks ago
Attention: Patch coverage is 87.50000%
with 1 line
in your changes missing coverage. Please review.
Project coverage is 94.3%. Comparing base (
4bfdc15
) to head (330d071
). Report is 6 commits behind head on main.
Files | Patch % | Lines |
---|---|---|
src/terminal/frame.rs | 0.0% | 1 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
I think we could do render_ref_with_state()
instead, but I'm fine with render_stateful_ref()
. Maybe check in with other maintainers before merging?
I think we could do
render_ref_with_state()
instead, but I'm fine withrender_stateful_ref()
. Maybe check in with other maintainers before merging?
I thought about that a little prior to writing this. The main pro for _stateful
is that it's in the name of the trait already, so it's kinda expected to be in the method name. The main pro for _with_state
seems is that it's a natural name for what this does. For me this feels like a 55/45 naming decision. I have a small amount of preference for _stateful, but would be convinced if there were good examples of _with_xxx on trait implementations in std
.
I have a preference for renaming these new trait names (the ones that are unstable) to Render
and RenderWithState
and then changing the names of the trait methods to match accordingly.
The disadvantage is that it would break from convention with the Widget
and StatefulWidget
traits. The advantage is that it is more consistent and clear (imo).
And I can see a world where everyone moves to using these new traits, and we deprecate the old ones and remove them eventually (a few years later?).
I have a preference for renaming these new trait names (the ones that are unstable) to
Render
andRenderWithState
and then changing the names of the trait methods to match accordingly.The disadvantage is that it would break from convention with the
Widget
andStatefulWidget
traits. The advantage is that it is more consistent and clear (imo).And I can see a world where everyone moves to using these new traits, and we deprecate the old ones and remove them eventually (a few years later?).
Let's move this point to a discussion on the forum.
Let's move this point to a discussion on the forum.
https://forum.ratatui.rs/t/naming-render-traits-methods/68
@kdheepak based on the logic in the above forum post are you happy to see this merged as is, or would you prefer to hold for a bit on this. It would be good to get it out in 0.27.0 perhaps.
Probably off-topic to this PR… why move this to a different place? Personally the forum feels like a place for "how to do this" and "showoffs". Stuff that should end in the code should be discussed as issues next to the code.
To the topic of naming the trait / methods… Personally I went to ratatui::widget::TRAIT::render(widget, …)
explicitly and that works well so far for me without naming conflicts. This is not ideal, but until there is a good way of handling this trait thing, good enough. Somehow this feels a bit rushed and all over the place to me currently. Discussion in multiple PR, the forum, …. This PR seems more like a draft to me currently. This might be a way to go forward. But it's nothing that should be merged for the next release as it will result in a lot of churn for sure.
I’d like to hold out till we figure out the naming, if that’s okay. Making one breaking change later (v0.28.0?) is better than making one now and potentially again one later.
Probably off-topic to this PR… why move this to a different place? Personally the forum feels like a place for "how to do this" and "showoffs". Stuff that should end in the code should be discussed as issues next to the code.
It is off-topic for this PR. If you ask about the rationale for this on the forum, I'll answer there... ;P
This commit renames the
StatefulWidgetRef::render_ref
method torender_stateful_ref
. This helps avoid collisions with theWidgetRef
trait'srender_ref
method. This change is breaking and requires updating all implementations ofStatefulWidgetRef
.BREAKING CHANGE:
StatefulWidgetRef::render_ref
has been renamed toStatefulWidgetRef::render_stateful_ref
.Partially addresses https://github.com/ratatui-org/ratatui/issues/996