mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 03:36:42 +01:00
re foreign trait constraints
This commit is contained in:
parent
ddf0c05d5f
commit
cbd28a5934
10 changed files with 30 additions and 24 deletions
|
|
@ -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"|
|
||||
|
|
|
|||
|
|
@ -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"),
|
||||
..
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue