dsl: auto-impl the obvious one (hopefully)
Some checks are pending
/ build (push) Waiting to run

re foreign trait constraints
This commit is contained in:
🪞👃🪞 2025-05-23 21:47:18 +03:00
parent ddf0c05d5f
commit cbd28a5934
10 changed files with 30 additions and 24 deletions

View file

@ -37,7 +37,7 @@ pub struct Align<A>(Alignment, A);
#[cfg(feature = "dsl")]
impl<'n, State: Give<A>, A: 'n> Take<'n, State> for Align<A> {
fn provide <'source> (state: &State, words: &mut TokenIter<'source>) -> Perhaps<Self> {
fn take <'source> (state: &State, words: &mut TokenIter<'source>) -> Perhaps<Self> {
if let Some(Token { value: Value::Key(key), .. }) = words.peek() {
match key {
"align/c"|"align/x"|"align/y"|

View file

@ -22,7 +22,7 @@ impl<E: Output, A: Content<E>, B: Content<E>> Content<E> for Bsp<A, B> {
}
#[cfg(feature = "dsl")]
impl<'n, State: Give<A> + Give<B>, A: 'n, B: 'n> Take<'n, State> for Bsp<A, B> {
fn provide <'source> (state: &State, words: &mut TokenIter<'source>) -> Perhaps<Self> {
fn take <'source> (state: &State, words: &mut TokenIter<'source>) -> Perhaps<Self> {
Ok(if let Some(Token {
value: Value::Key("bsp/n"|"bsp/s"|"bsp/e"|"bsp/w"|"bsp/a"|"bsp/b"),
..

View file

@ -10,7 +10,7 @@ impl<A, B> Either<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 provide <'source> (state: &State, token: &mut TokenIter<'source>) -> Perhaps<Self> {
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();

View file

@ -1,7 +1,7 @@
//! [Content] items that modify the inherent
//! dimensions of their inner [Render]ables.
//!
//! Transform may also react to the [Area] provided.
//! Transform may also react to the [Area] taked.
//! ```
//! use ::tengri::{output::*, tui::*};
//! let area: [u16;4] = [10, 10, 20, 20];
@ -34,7 +34,7 @@ macro_rules! transform_xy {
}
#[cfg(feature = "dsl")]
impl<'n, A: 'n, T: Give<A>> Take<'n, T> for $Enum<A> {
fn provide <'source> (state: &T, token: &mut TokenIter<'source>)
fn take <'source> (state: &T, token: &mut TokenIter<'source>)
-> Perhaps<Self>
{
if let Some(Token { value: Value::Key(k), .. }) = token.peek() {
@ -80,7 +80,7 @@ macro_rules! transform_xy_unit {
}
#[cfg(feature = "dsl")]
impl<'n, A: 'n, U: Coordinate + 'n, T: Give<A> + Give<U>> Take<'n, T> for $Enum<U, A> {
fn provide <'source> (
fn take <'source> (
state: &T, token: &mut TokenIter<'source>
) -> Perhaps<Self> {
Ok(if let Some(Token { value: Value::Key($x|$y|$xy), .. }) = token.peek() {

View file

@ -12,7 +12,7 @@ impl<A> When<A> {
#[cfg(feature = "dsl")]
impl<'n, State: Give<bool>, A: Take<'n, State>> Take<'n, State> for When<A> {
fn provide <'source> (state: &State, words: &mut TokenIter<'source>) -> Perhaps<Self> {
fn take <'source> (state: &State, words: &mut TokenIter<'source>) -> Perhaps<Self> {
Ok(if let Some(Token {
value: Value::Key("when"),
..
@ -21,7 +21,7 @@ impl<'n, State: Give<bool>, A: Take<'n, State>> Take<'n, State> for When<A> {
let base = words.clone();
return Ok(Some(Self(
state.give_or_fail(words, ||"cond: no condition")?,
A::provide_or_fail(state, words, ||"cond: no content")?,
A::take_or_fail(state, words, ||"cond: no content")?,
)))
} else {
None