wip: fix implicit static

This commit is contained in:
🪞👃🪞 2024-09-09 17:49:50 +03:00
parent eeb323b742
commit 49d2055147
6 changed files with 27 additions and 27 deletions

View file

@ -1,21 +1,5 @@
use crate::*;
/// A UI component.
pub trait Component<E: Engine>: Widget<Engine = E> + Handle<E> {}
/// Everything that implements [Render] and [Handle] is a [Component].
impl<E: Engine, C: Widget<Engine = E> + Handle<E>> Component<E> for C {}
/// Marker trait for [Component]s that can [Exit]
pub trait ExitableComponent<E>: Exit + Component<E> where E: Engine {
/// Perform type erasure for collecting heterogeneous components.
fn boxed (self) -> Box<dyn ExitableComponent<E>> where Self: Sized + 'static {
Box::new(self)
}
}
impl<E: Engine, C: Component<E> + Exit> ExitableComponent<E> for C {}
pub trait Widget {
type Engine: Engine;
fn layout (&self, to: <<Self as Widget>::Engine as Engine>::Area) ->
@ -23,7 +7,7 @@ pub trait Widget {
fn render (&self, to: &mut Self::Engine) ->
Perhaps<<<Self as Widget>::Engine as Engine>::Area>;
}
impl<E: Engine> Widget for Box<dyn Widget<Engine = E>> {
impl<'a, E: Engine> Widget for Box<dyn Widget<Engine = E> + 'a> {
type Engine = E;
fn layout (&self, to: E::Area) -> Perhaps<E::Area> {
(**self).layout(to)
@ -105,3 +89,9 @@ impl<E: Engine, W> Widget for W where W: Content<Engine = E> {
self.content().render(to)
}
}
/// A UI component.
pub trait Component<E: Engine>: Widget<Engine = E> + Handle<E> {}
/// Everything that implements [Render] and [Handle] is a [Component].
impl<E: Engine, C: Widget<Engine = E> + Handle<E>> Component<E> for C {}