implement iter_south with single iterator

This commit is contained in:
facile pop culture reference 2026-08-06 08:32:48 +03:00
parent ac9fd7dfba
commit b09719993a

View file

@ -43,10 +43,23 @@ pub fn iter_east_fixed <'a, S: Screen, D: 'a, I: Iterator<Item = D>, U: Draw<S>>
draw(move|_to: &mut S|{ todo!() })
}
pub fn iter_south <'a, S: Screen, D: 'a, I: Iterator<Item = D>, U: Draw<S>> (
_iter: impl Fn()->I, _draw: impl Fn(D, usize)->U,
pub fn iter_south <'a, S: Screen, D: Draw<S>, I: Iterator<Item = D>> (
iter: impl Fn()->I
) -> impl Draw<S> {
draw(move|_to: &mut S|{ todo!() })
draw(move|to: &mut S|{
let XYWH(x, mut y, w, mut h) = to.area();
let h0 = h;
for item in iter() {
if let Some(used) = to.draw(Some(XYWH(x, y, w, h)), item)? {
y = y.add(used.y());
h = h.minus(used.y());
if h == S::Unit::zero() {
break;
}
}
}
Ok(Some(XYWH(x, y, w, h)))
})
}
pub fn iter_south_fixed <'a, S: Screen, D: 'a, I: Iterator<Item = D>, U: Draw<S>> (