mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
once again, why did i begin to refactor this
This commit is contained in:
parent
297f9b30df
commit
798de37172
15 changed files with 582 additions and 602 deletions
|
|
@ -1,4 +1,5 @@
|
|||
use crate::*;
|
||||
use RefAtom::*;
|
||||
/// Show an item only when a condition is true.
|
||||
pub struct When<E, A>(pub PhantomData<E>, pub bool, pub A);
|
||||
impl<E, A> When<E, A> {
|
||||
|
|
@ -6,11 +7,10 @@ impl<E, A> When<E, A> {
|
|||
Self(Default::default(), c, a)
|
||||
}
|
||||
}
|
||||
impl<'a, E: Output + 'a, T: EdnViewData<'a, E>> TryFromEdn<'a, T> for When<E, RenderBox<'a, E>> {
|
||||
impl<'a, E: Output + 'a, T: ViewContext<'a, E>> TryFromEdn<'a, T> for When<E, RenderBox<'a, E>> {
|
||||
fn try_from_edn (
|
||||
state: &'a T, head: &Atom<impl AsRef<str>>, tail: &'a [Atom<impl AsRef<str>>]
|
||||
state: &'a T, head: &impl Atom, tail: &'a [impl Atom]
|
||||
) -> Option<Self> {
|
||||
use Atom::*;
|
||||
if let (Key("when"), [condition, content]) = (head.to_ref(), tail) {
|
||||
Some(Self(
|
||||
Default::default(),
|
||||
|
|
@ -47,9 +47,8 @@ impl<E, A, B> Either<E, A, B> {
|
|||
Self(Default::default(), c, a, b)
|
||||
}
|
||||
}
|
||||
impl<'a, E: Output + 'a, T: EdnViewData<'a, E>> TryFromEdn<'a, T> for Either<E, RenderBox<'a, E>, RenderBox<'a, E>> {
|
||||
fn try_from_edn (state: &'a T, head: &Atom<impl AsRef<str>>, tail: &'a [Atom<impl AsRef<str>>]) -> Option<Self> {
|
||||
use Atom::*;
|
||||
impl<'a, E: Output + 'a, T: ViewContext<'a, E>> TryFromEdn<'a, T> for Either<E, RenderBox<'a, E>, RenderBox<'a, E>> {
|
||||
fn try_from_edn (state: &'a T, head: &impl Atom, tail: &'a [impl Atom]) -> Option<Self> {
|
||||
if let (Key("either"), [condition, content, alternative]) = (head.to_ref(), tail) {
|
||||
Some(Self::new(
|
||||
state.get_bool(condition).expect("either: no condition"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue