mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 19:56:44 +01:00
dsl: Provide -> Take, Receive -> Give (swap + shorten)
This commit is contained in:
parent
583660c330
commit
ddf0c05d5f
10 changed files with 64 additions and 55 deletions
|
|
@ -36,7 +36,7 @@ pub enum Alignment { #[default] Center, X, Y, NW, N, NE, E, SE, S, SW, W }
|
|||
pub struct Align<A>(Alignment, A);
|
||||
|
||||
#[cfg(feature = "dsl")]
|
||||
impl<'n, State: Receive<A>, A: 'n> Provide<'n, State> for Align<A> {
|
||||
impl<'n, State: Give<A>, A: 'n> Take<'n, State> for Align<A> {
|
||||
fn provide <'source> (state: &State, words: &mut TokenIter<'source>) -> Perhaps<Self> {
|
||||
if let Some(Token { value: Value::Key(key), .. }) = words.peek() {
|
||||
match key {
|
||||
|
|
@ -44,7 +44,7 @@ impl<'n, State: Receive<A>, A: 'n> Provide<'n, State> for Align<A> {
|
|||
"align/n"|"align/s"|"align/e"|"align/w"|
|
||||
"align/nw"|"align/sw"|"align/ne"|"align/se" => {
|
||||
let _ = words.next().unwrap();
|
||||
let content = state.receive_or_fail(&mut words.clone(), ||"expected content")?;
|
||||
let content = state.give_or_fail(&mut words.clone(), ||"expected content")?;
|
||||
return Ok(Some(match key {
|
||||
"align/c" => Self::c(content),
|
||||
"align/x" => Self::x(content),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue