remove View and lifetime from Draw/Drawn
Some checks failed
/ build (push) Has been cancelled

This commit is contained in:
facile pop culture reference 2026-08-23 11:29:40 +03:00
parent 41ef62146b
commit 4172fa2577
13 changed files with 250 additions and 248 deletions

View file

@ -10,11 +10,11 @@ fn_kw_layout!(kw_when |state, output, expr| {
/// Only render when condition is true.
///
/// ```
/// # use ::tengri::*; fn test <'a> () -> impl Draw<'a, Tui> {
/// # use ::tengri::*; fn test <'a> () -> impl Draw<Tui> {
/// when(true, "Yes")
/// # }
/// ```
pub const fn when <'a, T: Screen> (condition: bool, item: impl Draw<'a, T>) -> impl Draw<'a, T> {
pub const fn when <'a, T: Screen> (condition: bool, item: impl Draw<T>) -> impl Draw<T> {
draw(move|to: &mut T|if condition { item.draw(to) } else { Ok(Default::default()) })
}
@ -29,12 +29,12 @@ fn_kw_layout!(kw_either |state, output, expr| {
/// Render one thing if a condition is true and another false.
///
/// ```
/// # use ::tengri::*; fn test <'a> () -> impl Draw<'a, Tui> {
/// # use ::tengri::*; fn test <'a> () -> impl Draw<Tui> {
/// either(true, "Yes", "No")
/// # }
/// ```
pub const fn either <'a, T: Screen> (
condition: bool, a: impl Draw<'a, T>, b: impl Draw<'a, T>
) -> impl Draw<'a, T> {
condition: bool, a: impl Draw<T>, b: impl Draw<T>
) -> impl Draw<T> {
draw(move|to: &mut T|if condition { a.draw(to) } else { b.draw(to) })
}