output: refactor Content and Render traits

This commit is contained in:
🪞👃🪞 2025-09-06 08:46:52 +03:00
parent 74b3af2212
commit 1c21a85f27
24 changed files with 346 additions and 613 deletions

View file

@ -6,7 +6,7 @@ impl<A> When<A> {
/// Create a binary condition.
pub const fn new (c: bool, a: A) -> Self { Self(c, a) }
}
impl<E: Output, A: Render<E>> Content<E> for When<A> {
impl<E: Output, A: Render<E>> Render<E> for When<A> {
fn layout (&self, to: E::Area) -> E::Area {
let Self(cond, item) = self;
let mut area = E::Area::zero();
@ -31,7 +31,7 @@ impl<A, B> Either<A, B> {
/// Create a ternary view condition.
pub const fn new (c: bool, a: A, b: B) -> Self { Self(c, a, b) }
}
impl<E: Output, A: Render<E>, B: Render<E>> Content<E> for Either<A, B> {
impl<E: Output, A: Render<E>, B: Render<E>> Render<E> for Either<A, B> {
fn layout (&self, to: E::Area) -> E::Area {
let Self(cond, a, b) = self;
if *cond { a.layout(to) } else { b.layout(to) }