trying to get new Bsp to work; update docs

This commit is contained in:
🪞👃🪞 2024-12-31 19:21:48 +01:00
parent c9b81edb45
commit 62ce1776c0
11 changed files with 301 additions and 157 deletions

View file

@ -31,17 +31,39 @@ pub trait Content<E: Engine>: Send + Sync {
}
impl<E: Engine> Content<E> for () {
fn area (&self, area: E::Area) -> E::Area {
fn area (&self, _: E::Area) -> E::Area {
[0.into(), 0.into(), 0.into(), 0.into()].into()
}
fn render (&self, output: &mut E::Output) {}
fn render (&self, _: &mut E::Output) {}
}
impl<E: Engine, T: Content<E>> Content<E> for &T {}
impl<E: Engine, T: Content<E>> Content<E> for &T {
fn content (&self) -> impl Content<E> {
(*self).content()
}
fn area (&self, area: E::Area) -> E::Area {
(*self).area(area)
}
fn render (&self, output: &mut E::Output) {
(*self).render(output)
}
}
impl<E: Engine, T: Content<E>> Content<E> for Option<T> {}
impl<E: Engine, T: Content<E>> Content<E> for Vec<T> {}
impl<E: Engine, T: Content<E>> Content<E> for Option<T> {
fn content (&self) -> impl Content<E> {
self.as_ref()
.map(|content|content.content())
}
fn area (&self, area: E::Area) -> E::Area {
self.as_ref()
.map(|content|content.area(area))
.unwrap_or([0.into(), 0.into(), 0.into(), 0.into(),].into())
}
fn render (&self, output: &mut E::Output) {
self.as_ref()
.map(|content|content.render(output));
}
}
pub struct Thunk<E: Engine, T: Content<E>, F: Fn()->T + Send + Sync>(F, PhantomData<E>);