wip: hook up more builtins

This commit is contained in:
🪞👃🪞 2025-01-13 23:39:06 +01:00
parent fa70a42bad
commit 811e341cd5
4 changed files with 94 additions and 64 deletions

View file

@ -37,32 +37,29 @@ pub trait EdnViewData<'a, E: Output>:
match item {
Nil => Box::new(()),
Exp(e) => if let [head, tail @ ..] = e.as_slice() {
if let Some(builtin) = When::<_, Box<dyn Render<E>>>::try_from_edn(self, head, tail) {
if let Some(builtin) = When::<_, RenderBox<'a, E>>::try_from_edn(self, head, tail) {
return builtin.boxed()
}
if let Some(builtin) = Either::<_, Box<dyn Render<E>>, Box<dyn Render<E>>>::try_from_edn(self, head, tail) {
if let Some(builtin) = Either::<_, RenderBox<'a, E>, RenderBox<'a, E>>::try_from_edn(
self, head, tail
) {
return builtin.boxed()
}
if let Some(builtin) = Align::<_, RenderBox<'a, E>>::try_from_edn(self, head, tail) {
return builtin.boxed()
}
if let Some(builtin) = Bsp::<_, RenderBox<'a, E>, RenderBox<'a, E>>::try_from_edn(
self, head, tail
) {
return builtin.boxed()
}
panic!("{item:?}");
match (head, tail) {
//(Key("when"), [c, a]) =>
//When(self.arg(c).unwrap(), self.get_content(a)).boxed(),
//(Key("either"), [c, a, b]) =>
//Either(self.arg(c).unwrap(), self.get_content(a), self.get_content(b)).boxed(),
(Key("align/c"), [a]) => Align::c(self.get_content(a)).boxed(),
(Key("align/x"), [a]) => Align::x(self.get_content(a)).boxed(),
(Key("align/y"), [a]) => Align::y(self.get_content(a)).boxed(),
(Key("align/n"), [a]) => Align::n(self.get_content(a)).boxed(),
(Key("align/s"), [a]) => Align::s(self.get_content(a)).boxed(),
(Key("align/e"), [a]) => Align::e(self.get_content(a)).boxed(),
(Key("align/w"), [a]) => Align::w(self.get_content(a)).boxed(),
(Key("align/nw"), [a]) => Align::nw(self.get_content(a)).boxed(),
(Key("align/ne"), [a]) => Align::ne(self.get_content(a)).boxed(),
(Key("align/sw"), [a]) => Align::sw(self.get_content(a)).boxed(),
(Key("align/se"), [a]) => Align::se(self.get_content(a)).boxed(),
(Key("bsp/a"), [a, b]) => Bsp::a(self.get_content(a), self.get_content(b),).boxed(),
(Key("bsp/b"), [a, b]) => Bsp::b(self.get_content(a), self.get_content(b),).boxed(),
(Key("bsp/e"), [a, b]) => Bsp::e(self.get_content(a), self.get_content(b),).boxed(),