mirror of https://github.com/linebender/xilem
![]() Having `Box<dyn Widget>` implement the `Widget` trait is a crutch that makes a bunch of things more complicated. It leads to double-boxing in cases when the `dyn Widget` is itself a `Box<dyn Widget>` (especially since the arena's current implementation boxes all widgets by default), makes it harder to reason about downcasting, and ends up producing a lot of code to handle the edge cases. On the xilem side, `Box<dyn Widget>` is slightly redundant with `DynWidget`. This PR still leaves a lot of boxing. On the long term, we'd like for the arena to pack arbitrary widgets efficiently using some kind of archetype scheme, but in the meantime, boxing will have to do. Changes in this PR: - New `FromDynWidget` trait that maybe-downcasts widgets to a maybe-sized `Widget` type. - Most places that accept `Widget` now accept `Widget + ?Sized`. - Remove `impl Widget for Box<dyn Widget>`. - Replace all instances of `WidgetPod<Box<dyn Widget>>` with `WidgetPod<dyn Widget>`. - Replace all instances of `xilem::Pod<Box<dyn Widget>>` with `xilem::Pod<dyn Widget>`. - Rename WidgetPod to WidgetBox in xilem_core example to avoid ambiguity. |
||
---|---|---|
.. | ||
filesystem.rs | ||
user_interface.rs |