mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-13 23:26:41 +01:00
getting there with the iters but still wrong
This commit is contained in:
parent
323afe4c89
commit
266f59085e
3 changed files with 32 additions and 35 deletions
|
|
@ -32,36 +32,33 @@ impl<E: Output, A: Content<E>, B: Content<E>> Content<E> for Bsp<A, B> {
|
|||
}
|
||||
}
|
||||
try_from_expr!(<'a, E>: Bsp<RenderBox<'a, E>, RenderBox<'a, E>>: |state, iter| {
|
||||
if let Some(Token { value: Value::Key(key), .. }) = iter.peek() {
|
||||
let iter = iter.clone().next().unwrap().1;
|
||||
match key {
|
||||
"bsp/n" => return Some(Self::n(
|
||||
state.get_content(&iter.next()?.0.value).expect("no south"),
|
||||
state.get_content(&iter.next()?.0.value).expect("no north")
|
||||
)),
|
||||
"bsp/s" => return Some(Self::s(
|
||||
state.get_content(&iter.next()?.0.value).expect("no north"),
|
||||
state.get_content(&iter.next()?.0.value).expect("no south")
|
||||
)),
|
||||
"bsp/e" => return Some(Self::e(
|
||||
state.get_content(&iter.next()?.0.value).expect("no west"),
|
||||
state.get_content(&iter.next()?.0.value).expect("no east")
|
||||
)),
|
||||
"bsp/w" => return Some(Self::w(
|
||||
state.get_content(&iter.next()?.0.value).expect("no east"),
|
||||
state.get_content(&iter.next()?.0.value).expect("no west")
|
||||
)),
|
||||
"bsp/a" => return Some(Self::a(
|
||||
state.get_content(&iter.next()?.0.value).expect("no above"),
|
||||
state.get_content(&iter.next()?.0.value).expect("no below")
|
||||
)),
|
||||
"bsp/b" => return Some(Self::b(
|
||||
state.get_content(&iter.next()?.0.value).expect("no above"),
|
||||
state.get_content(&iter.next()?.0.value).expect("no below")
|
||||
)),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
Some(if let Some((Token { value: Value::Key("bsp/n"), .. }, iter)) = iter.next() {
|
||||
let (s, iter) = iter.next().map(|(c, iter)|(state.get_content(&c.value).expect("no south provided"), iter)).expect("no south specified");
|
||||
let (n, _) = iter.next().map(|(c, iter)|(state.get_content(&c.value).expect("no north provided"), iter)).expect("no north specified");
|
||||
Self::n(s, n)
|
||||
} else if let Some((Token { value: Value::Key("bsp/s"), .. }, iter)) = iter.next() {
|
||||
let (n, iter) = iter.next().map(|(c, iter)|(state.get_content(&c.value).expect("no north provided"), iter)).expect("no north specified");
|
||||
let (s, _) = iter.next().map(|(c, iter)|(state.get_content(&c.value).expect("no south provided"), iter)).expect("no south specified");
|
||||
Self::s(n, s)
|
||||
} else if let Some((Token { value: Value::Key("bsp/e"), .. }, iter)) = iter.next() {
|
||||
let (w, iter) = iter.next().map(|(c, iter)|(state.get_content(&c.value).expect("no west provided"), iter)).expect("no west specified");
|
||||
let (e, _) = iter.next().map(|(c, iter)|(state.get_content(&c.value).expect("no east provided"), iter)).expect("no east specified");
|
||||
Self::e(w, e)
|
||||
} else if let Some((Token { value: Value::Key("bsp/w"), .. }, iter)) = iter.next() {
|
||||
let (e, iter) = iter.next().map(|(c, iter)|(state.get_content(&c.value).expect("no west provided"), iter)).expect("no west specified");
|
||||
let (w, _) = iter.next().map(|(c, iter)|(state.get_content(&c.value).expect("no east provided"), iter)).expect("no east specified");
|
||||
Self::w(e, w)
|
||||
} else if let Some((Token { value: Value::Key("bsp/a"), .. }, iter)) = iter.next() {
|
||||
let (a, iter) = iter.next().map(|(c, iter)|(state.get_content(&c.value).expect("no above provided"), iter)).expect("no above specified");
|
||||
let (b, _) = iter.next().map(|(c, iter)|(state.get_content(&c.value).expect("no below provided"), iter)).expect("no below specified");
|
||||
Self::a(a, b)
|
||||
} else if let Some((Token { value: Value::Key("bsp/b"), .. }, iter)) = iter.next() {
|
||||
let (a, iter) = iter.next().map(|(c, iter)|(state.get_content(&c.value).expect("no above provided"), iter)).expect("no above specified");
|
||||
let (b, _) = iter.next().map(|(c, iter)|(state.get_content(&c.value).expect("no below provided"), iter)).expect("no below specified");
|
||||
Self::b(a, b)
|
||||
} else {
|
||||
return None
|
||||
})
|
||||
});
|
||||
impl<A, B> Bsp<A, B> {
|
||||
pub fn n (a: A, b: B) -> Self { Self(North, a, b) }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue