Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Add a render method for the Widget trait that takes by reference instead #528

Closed
wants to merge 1 commit into from
Closed

Add a render method for the Widget trait that takes by reference instead #528

wants to merge 1 commit into from

Conversation

SergeyKasmy
Copy link

Description

This PR adds Terminal::render_widget_ref() and (Stateful)Widget::render_ref() functions that take Widgets by reference instead of taking ownership. This allows to call render on a Trait object with unknown size with is useful where the exact object implementing Widget is unknown or depends on some kind of condition. I decided not to change the render_widget() and render() signatures as to keep backwards compatibility but sadly all custom widgets are still broken because they are now required to implement render_ref() instead. This is just a proof of concept PR and I would appreciate any help on getting it up to the standards since this is my first time contributing to a big rust project. I made this to fix issue #526 I posted yesterday and I'm already using this PR in a project of mine.

Checklist

@harrypunk
Copy link

Super helpful feature. I'm looking for a way of rendering a dynamic widget.

@kroonhorstdino
Copy link

Would definitely like to see this feature merged! Would make my life so much easier, right now you have to work around so much limitations in that regard.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants