mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 19:56:44 +01:00
wip: dsl, output, input, proc, tui: sorting out give and take
Some checks are pending
/ build (push) Waiting to run
Some checks are pending
/ build (push) Waiting to run
This commit is contained in:
parent
5a2177cc77
commit
3e1084555b
10 changed files with 273 additions and 301 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue