Add Boxed and BoxedAsync widgets

This commit is contained in:
Joscha 2023-04-08 16:00:04 +02:00
parent 007493f136
commit 7c6e651f88
3 changed files with 134 additions and 1 deletions

View file

@ -1,7 +1,8 @@
use async_trait::async_trait;
use crate::widgets::{
Background, Border, Either2, Either3, Float, JoinSegment, Layer2, Padding, Resize,
Background, Border, Boxed, BoxedAsync, Either2, Either3, Float, JoinSegment, Layer2, Padding,
Resize,
};
use crate::{Frame, Size, WidthDb};
@ -39,6 +40,20 @@ pub trait WidgetExt: Sized {
Border::new(self)
}
fn boxed<'a, E>(self) -> Boxed<'a, E>
where
Self: Widget<E> + 'a,
{
Boxed::new(self)
}
fn boxed_async<'a, E>(self) -> BoxedAsync<'a, E>
where
Self: AsyncWidget<E> + Send + Sync + 'a,
{
BoxedAsync::new(self)
}
fn first2<W2>(self) -> Either2<Self, W2> {
Either2::First(self)
}