mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 19:56:44 +01:00
wip: finally, informative type errors from the macro
Some checks failed
/ build (push) Has been cancelled
Some checks failed
/ build (push) Has been cancelled
fixin mixin
This commit is contained in:
parent
abc87d3234
commit
583660c330
10 changed files with 152 additions and 205 deletions
|
|
@ -33,19 +33,19 @@ macro_rules! transform_xy {
|
|||
#[inline] pub const fn xy (item: A) -> Self { Self::XY(item) }
|
||||
}
|
||||
#[cfg(feature = "dsl")]
|
||||
impl<A, T: Dsl<A>> Namespace<T> for $Enum<A> {
|
||||
fn take_from <'source> (
|
||||
state: &T, token: &mut TokenIter<'source>
|
||||
) -> Perhaps<Self> {
|
||||
impl<'n, A: 'n, T: Receive<A>> Provide<'n, T> for $Enum<A> {
|
||||
fn provide <'source> (state: &T, token: &mut TokenIter<'source>)
|
||||
-> Perhaps<Self>
|
||||
{
|
||||
if let Some(Token { value: Value::Key(k), .. }) = token.peek() {
|
||||
let mut base = token.clone();
|
||||
return Ok(Some(match token.next() {
|
||||
Some(Token{value:Value::Key($x),..}) =>
|
||||
Self::x(state.take_or_fail(token, ||"x: no content")?),
|
||||
Self::x(state.receive_or_fail(token, ||"x: no content")?),
|
||||
Some(Token{value:Value::Key($y),..}) =>
|
||||
Self::y(state.take_or_fail(token, ||"y: no content")?),
|
||||
Self::y(state.receive_or_fail(token, ||"y: no content")?),
|
||||
Some(Token{value:Value::Key($xy),..}) =>
|
||||
Self::xy(state.take_or_fail(token, ||"xy: no content")?),
|
||||
Self::xy(state.receive_or_fail(token, ||"xy: no content")?),
|
||||
_ => unreachable!()
|
||||
}))
|
||||
}
|
||||
|
|
@ -79,25 +79,25 @@ macro_rules! transform_xy_unit {
|
|||
#[inline] pub const fn xy (x: U, y: U, item: A) -> Self { Self::XY(x, y, item) }
|
||||
}
|
||||
#[cfg(feature = "dsl")]
|
||||
impl<A, U: Coordinate, T: Dsl<A> + Dsl<U>> Namespace<T> for $Enum<U, A> {
|
||||
fn take_from <'source> (
|
||||
impl<'n, A: 'n, U: Coordinate + 'n, T: Receive<A> + Receive<U>> Provide<'n, T> for $Enum<U, A> {
|
||||
fn provide <'source> (
|
||||
state: &T, token: &mut TokenIter<'source>
|
||||
) -> Perhaps<Self> {
|
||||
Ok(if let Some(Token { value: Value::Key($x|$y|$xy), .. }) = token.peek() {
|
||||
let mut base = token.clone();
|
||||
Some(match token.next() {
|
||||
Some(Token { value: Value::Key($x), .. }) => Self::x(
|
||||
state.take_or_fail(token, ||"x: no unit")?,
|
||||
state.take_or_fail(token, ||"x: no content")?,
|
||||
state.receive_or_fail(token, ||"x: no unit")?,
|
||||
state.receive_or_fail(token, ||"x: no content")?,
|
||||
),
|
||||
Some(Token { value: Value::Key($y), .. }) => Self::y(
|
||||
state.take_or_fail(token, ||"y: no unit")?,
|
||||
state.take_or_fail(token, ||"y: no content")?,
|
||||
state.receive_or_fail(token, ||"y: no unit")?,
|
||||
state.receive_or_fail(token, ||"y: no content")?,
|
||||
),
|
||||
Some(Token { value: Value::Key($x), .. }) => Self::xy(
|
||||
state.take_or_fail(token, ||"xy: no unit x")?,
|
||||
state.take_or_fail(token, ||"xy: no unit y")?,
|
||||
state.take_or_fail(token, ||"xy: no content")?
|
||||
state.receive_or_fail(token, ||"xy: no unit x")?,
|
||||
state.receive_or_fail(token, ||"xy: no unit y")?,
|
||||
state.receive_or_fail(token, ||"xy: no content")?
|
||||
),
|
||||
_ => unreachable!(),
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue