wip: dsl, output, input, proc, tui: sorting out give and take
Some checks are pending
/ build (push) Waiting to run

This commit is contained in:
🪞👃🪞 2025-05-24 23:57:12 +03:00
parent 5a2177cc77
commit 3e1084555b
10 changed files with 273 additions and 301 deletions

View file

@ -8,21 +8,18 @@ impl<A, B> Either<A, B> {
Self(c, a, b)
}
}
#[cfg(feature = "dsl")]
impl<'n, State: Give<bool> + Give<A> + Give<B>, A: 'n, B: 'n> Take<'n, State> for Either<A, B> {
fn take <'source> (state: &State, token: &mut TokenIter<'source>) -> Perhaps<Self> {
if let Some(Token { value: Value::Key("either"), .. }) = token.peek() {
let base = token.clone();
let _ = token.next().unwrap();
return Ok(Some(Self(
state.give_or_fail(token, ||"either: no condition")?,
state.give_or_fail(token, ||"either: no content 1")?,
state.give_or_fail(token, ||"either: no content 2")?,
)))
}
Ok(None)
}
}
#[cfg(feature = "dsl")] take!(Either<A, B>, A, B|state, words|Ok(
if let Some(Token { value: Value::Key("either"), .. }) = words.peek() {
let base = words.clone();
let _ = words.next().unwrap();
return Ok(Some(Self(
state.give_or_fail(words, ||"either: no condition")?,
state.give_or_fail(words, ||"either: no content 1")?,
state.give_or_fail(words, ||"either: no content 2")?,
)))
} else {
None
}));
impl<E: Output, A: Render<E>, B: Render<E>> Content<E> for Either<A, B> {
fn layout (&self, to: E::Area) -> E::Area {
let Self(cond, a, b) = self;