well, it compiles. fails on run, though

This commit is contained in:
🪞👃🪞 2025-01-18 16:32:04 +01:00
parent a362028ae7
commit d14d67172c
6 changed files with 96 additions and 185 deletions

View file

@ -12,9 +12,9 @@ macro_rules! transform_xy {
pub fn y (item: T) -> Self { Self::Y(item) }
pub fn xy (item: T) -> Self { Self::XY(item) }
}
impl<'a, E: Output + 'a, T: ViewContext<'a, E>> TryFromAtom<T>
impl<'a, E: Output + 'a, T: ViewContext<'a, E>> TryFromAtom<'a, T>
for $Enum<RenderBox<'a, E>> {
fn try_from_expr (state: &T, iter: TokenIter) -> Option<Self> {
fn try_from_expr (state: &'a T, iter: TokenIter<'a>) -> Option<Self> {
Some(if let Some((Token { value: Value::Key($x), .. }, _)) = iter.next() {
Self::x(state.get_content(&iter.next().expect("no content").0.value).expect("no content"))
} else if let Some((Token { value: Value::Key($y), .. }, _)) = iter.next() {
@ -51,20 +51,20 @@ macro_rules! transform_xy_unit {
pub fn y (y: U, item: T) -> Self { Self::Y(y, item) }
pub fn xy (x: U, y: U, item: T) -> Self { Self::XY(x, y, item) }
}
impl<'a, E: Output + 'a, T: ViewContext<'a, E>> TryFromAtom<T>
impl<'a, E: Output + 'a, T: ViewContext<'a, E>> TryFromAtom<'a, T>
for $Enum<E::Unit, RenderBox<'a, E>> {
fn try_from_expr (state: &T, iter: TokenIter) -> Option<Self> {
fn try_from_expr (state: &'a T, iter: TokenIter<'a>) -> Option<Self> {
Some(if let Some((Token { value: Value::Key($x), .. }, _)) = iter.next() {
let x = state.get_unit(&iter.next().expect("no x").0.value).expect("no x");
let x = state.get(&iter.next().expect("no x").0.value).expect("no x");
let c = state.get_content(&iter.next().expect("no content").0.value).expect("no content");
Self::x(x, c)
} else if let Some((Token { value: Value::Key($y), .. }, _)) = iter.next() {
let y = state.get_unit(&iter.next().expect("no y").0.value).expect("no y");
let y = state.get(&iter.next().expect("no y").0.value).expect("no y");
let c = state.get_content(&iter.next().expect("no content").0.value).expect("no content");
Self::y(y, c)
} else if let Some((Token { value: Value::Key($xy), .. }, _)) = iter.next() {
let x = state.get_unit(&iter.next().expect("no x").0.value).expect("no x");
let y = state.get_unit(&iter.next().expect("no y").0.value).expect("no y");
let x = state.get(&iter.next().expect("no x").0.value).expect("no x");
let y = state.get(&iter.next().expect("no y").0.value).expect("no y");
let c = state.get_content(&iter.next().expect("no content").0.value).expect("no content");
Self::xy(x, y, c)
} else {