0.7.1: log unresolved content in all cases

This commit is contained in:
🪞👃🪞 2025-04-13 21:49:18 +03:00
parent f33f331a48
commit 34295570a2
7 changed files with 70 additions and 39 deletions

View file

@ -42,12 +42,3 @@ pub type Perhaps<T> = Result<Option<T>, Box<dyn Error>>;
}
Ok(())
}
#[cfg(test)] #[test] fn test_dimensions () {
use crate::*;
assert_eq!(Area::center(&[10u16, 10, 20, 20]), [20, 20]);
}
#[cfg(test)] #[test] fn test_layout () -> Usually<()> {
Ok(())
}

View file

@ -1,3 +1,5 @@
use crate::*;
mod align; pub use self::align::*;
mod bsp; pub use self::bsp::*;
mod cond; pub use self::cond::*;

View file

@ -40,20 +40,24 @@ try_from_expr!(<'a, E>: Align<RenderBox<'a, E>>: |state, iter|{
"align/n"|"align/s"|"align/e"|"align/w"|
"align/nw"|"align/sw"|"align/ne"|"align/se" => {
let _ = iter.next().unwrap();
let c = iter.next().expect("no content specified");
let c = state.get_content(&c.value).expect("no content provided");
let content = iter.next().expect("no content specified");
let content = if let Some(content) = state.get_content(&content.value) {
content
} else {
panic!("no content corresponding to {:?}", &content);
};
return Some(match key {
"align/c" => Self::c(c),
"align/x" => Self::x(c),
"align/y" => Self::y(c),
"align/n" => Self::n(c),
"align/s" => Self::s(c),
"align/e" => Self::e(c),
"align/w" => Self::w(c),
"align/nw" => Self::nw(c),
"align/ne" => Self::ne(c),
"align/sw" => Self::sw(c),
"align/se" => Self::se(c),
"align/c" => Self::c(content),
"align/x" => Self::x(content),
"align/y" => Self::y(content),
"align/n" => Self::n(content),
"align/s" => Self::s(content),
"align/e" => Self::e(content),
"align/w" => Self::w(content),
"align/nw" => Self::nw(content),
"align/ne" => Self::ne(content),
"align/sw" => Self::sw(content),
"align/se" => Self::se(content),
_ => unreachable!()
})
},

View file

@ -22,10 +22,17 @@ impl<A, B> Either<A, B> {
try_from_expr!(<'a, E>: When<RenderBox<'a, E>>: |state, iter| {
if let Some(Token { value: Value::Key("when"), .. }) = iter.peek() {
let _ = iter.next().unwrap();
let condition = iter.next().expect("no condition specified");
let content = iter.next().expect("no content specified");
let condition = state.get(&condition.value).expect("no condition provided");
let content = state.get_content(&content.value).expect("no content provided");
let content = iter.next().expect("no content specified");
let content = if let Some(content) = state.get_content(&content.value) {
content
} else {
panic!("no content corresponding to for {:?}", &content);
};
return Some(Self(condition, content))
}
});
@ -34,12 +41,24 @@ try_from_expr!(<'a, E>: When<RenderBox<'a, E>>: |state, iter| {
try_from_expr!(<'a, E>: Either<RenderBox<'a, E>, RenderBox<'a, E>>: |state, iter| {
if let Some(Token { value: Value::Key("either"), .. }) = iter.peek() {
let _ = iter.next().unwrap();
let condition = iter.next().expect("no condition specified");
let content = iter.next().expect("no content specified");
let alternate = iter.next().expect("no alternate specified");
let condition = state.get(&condition.value).expect("no condition provided");
let content = state.get_content(&content.value).expect("no content provided");
let alternate = state.get_content(&alternate.value).expect("no alternate provided");
let content = iter.next().expect("no content specified");
let content = if let Some(content) = state.get_content(&content.value) {
content
} else {
panic!("no content 1 corresponding to {:?}", &content);
};
let alternate = iter.next().expect("no alternate specified");
let alternate = if let Some(alternate) = state.get_content(&alternate.value) {
alternate
} else {
panic!("no content 2 corresponding to {:?}", &alternate);
};
return Some(Self(condition, content, alternate))
}
});

View file

@ -90,10 +90,17 @@ macro_rules! transform_xy_unit {
if let Some(Token { value: Value::Key(k), .. }) = iter.peek() {
if k == $x || k == $y {
let _ = iter.next().unwrap();
let u = iter.next().expect("no unit specified");
let c = iter.next().expect("no content specified");
let u = state.get(&u.value).expect("no unit provided");
let c = state.get_content(&c.value).expect("no content provided");
let c = iter.next().expect("no content specified");
let c = if let Some(c) = state.get_content(&c.value) {
c
} else {
panic!("no content corresponding to {:?}", &c);
};
return Some(match k {
$x => Self::x(u, c),
$y => Self::y(u, c),
@ -101,12 +108,20 @@ macro_rules! transform_xy_unit {
})
} else if k == $xy {
let _ = iter.next().unwrap();
let u = iter.next().expect("no unit specified");
let u = state.get(&u.value).expect("no x unit provided");
let v = iter.next().expect("no unit specified");
let v = state.get(&v.value).expect("no y unit provided");
let c = iter.next().expect("no content specified");
let u = state.get(&u.value).expect("no unit provided");
let v = state.get(&v.value).expect("no unit provided");
let c = state.get_content(&c.value).expect("no content provided");
let c = if let Some(c) = state.get_content(&c.value) {
c
} else {
panic!("no content corresponding to {:?}", &c);
};
return Some(Self::xy(u, v, c))
}
}