Skip to content
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

Any, Menu, MenuBar improvements #97

Merged
merged 11 commits into from
Apr 29, 2020
Merged

Any, Menu, MenuBar improvements #97

merged 11 commits into from
Apr 29, 2020

Conversation

dhardy
Copy link
Collaborator

@dhardy dhardy commented Apr 29, 2020

This restricts Widget: Any and adds some methods around this. This functionality is not currently used, but seems worth having. As a side-effect, this requires that Widget::Msg: 'static. As the commit notes, message types with lifetime restrictions might otherwise have been feasible, but likely wouldn't be used much and would increase complexity and add another requirement on nightly Rust.

This also adds a Menu trait and uses it to improve menu behaviour, fixing #96. This allows Event::OpenPopup and ClosePopup to be removed. As noted in #96, having to use a separate menu trait seems unfortunate, but isn't that big a deal. Some alternatives I decided against:

  • add the extra functionality to all widgets
  • parametrise the Widget trait over an extension trait, and add fn as_extension_mut
  • use generic recursion over children, and attempt downcasting each to SubMenu (this would prevent custom sub-menus)

The Any bound requires the latter bound. Note that without
this bound, using a Msg with 'a could be possible but would
require parametrising Msg over 'a; the latter requires GATs
(unstable). Probably this would be more complex than useful.
This makes Event::OpenPopup and ClosePopup obsolete.
@dhardy dhardy merged commit 4c7fd34 into master Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant