mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
parent
73748e1fb9
commit
4a2e742e56
2 changed files with 10 additions and 4 deletions
|
|
@ -4,6 +4,11 @@ pub(crate) use ::tengri::tui::ratatui::prelude::Position;
|
||||||
|
|
||||||
// Thunks can be natural error boundaries!
|
// Thunks can be natural error boundaries!
|
||||||
struct ErrorBoundary<O: Output, T: Content<O>>(std::marker::PhantomData<O>, Perhaps<T>);
|
struct ErrorBoundary<O: Output, T: Content<O>>(std::marker::PhantomData<O>, Perhaps<T>);
|
||||||
|
impl<O: Output, T: Content<O>> ErrorBoundary<O, T> {
|
||||||
|
pub fn new (content: Perhaps<T>) -> Self {
|
||||||
|
Self(Default::default(), content)
|
||||||
|
}
|
||||||
|
}
|
||||||
impl<T: Content<TuiOut>> Content<TuiOut> for ErrorBoundary<TuiOut, T> {
|
impl<T: Content<TuiOut>> Content<TuiOut> for ErrorBoundary<TuiOut, T> {
|
||||||
fn content (&self) -> impl Render<TuiOut> + '_ {
|
fn content (&self) -> impl Render<TuiOut> + '_ {
|
||||||
ThunkRender::new(|to|match self.1.as_ref() {
|
ThunkRender::new(|to|match self.1.as_ref() {
|
||||||
|
|
@ -19,9 +24,10 @@ impl<T: Content<TuiOut>> Content<TuiOut> for ErrorBoundary<TuiOut, T> {
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
pub fn view (model: &Self) -> impl Content<TuiOut> + '_ {
|
pub fn view (model: &Self) -> impl Content<TuiOut> + '_ {
|
||||||
ErrorBoundary::<TuiOut, Box<dyn Render<TuiOut> + '_>>(
|
ErrorBoundary::new(
|
||||||
Default::default(),
|
Ok(Some(Tui::bg(Black, "give or take")))
|
||||||
Give::give(model, &mut model.config.view.clone())
|
//Default::default(), Take::take(model, &mut model.config.view.clone())
|
||||||
|
//Default::default(), Give::give(model, &mut model.config.view.clone())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
deps/tengri
vendored
2
deps/tengri
vendored
|
|
@ -1 +1 @@
|
||||||
Subproject commit cbd28a5934a7a2a9f7c48faa92bfe7ba52440919
|
Subproject commit 5a2177cc77fd8827b565a2bf08c18d6bc25ea0dd
|
||||||
Loading…
Add table
Add a link
Reference in a new issue