From 29035d0b36221f43902ead396a5e94c423f0581d Mon Sep 17 00:00:00 2001 From: facile pop culture reference Date: Tue, 16 Jun 2026 14:58:48 +0300 Subject: [PATCH] add index to all iter helpers --- src/draw.rs | 5 +++++ src/space/iter.rs | 17 ++++++++--------- src/term/border.rs | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/draw.rs b/src/draw.rs index 76dc916..a76126b 100644 --- a/src/draw.rs +++ b/src/draw.rs @@ -49,6 +49,11 @@ pub use self::screen::*; pub trait Draw { fn draw (self, to: &mut T) -> Usually>; } +impl Draw for () { + fn draw (self, __: &mut T) -> Usually> { + Ok(Default::default()) + } +} impl> Draw for &D { fn draw (self, __: &mut T) -> Usually> { todo!() diff --git a/src/space/iter.rs b/src/space/iter.rs index a431f3d..4277d05 100644 --- a/src/space/iter.rs +++ b/src/space/iter.rs @@ -11,23 +11,23 @@ use super::*; /// ].iter(), |x|x); /// ``` pub fn iter < - S: Screen, - D: Draw, - V: Fn()->I, - I: Iterator, - F: Fn(&D)->dyn Draw, + S: Screen, // Target screen + D, // Input doesn't need to be [Draw]able, output does + V: Fn()->I, // Function that returns the iterator + I: Iterator, // Type of the iterator + F: Fn(&D, usize)->dyn Draw, // Function that returns [Draw]able from iterator item > (_items: V, _cb: F) -> impl Draw { thunk(move|_to: &mut S|{ todo!() }) } pub fn iter_north <'a, S: Screen, D: 'a, I: Iterator, U: Draw> ( - _iter: impl Fn()->I, _draw: impl Fn(D)->U, + _iter: impl Fn()->I, _draw: impl Fn(D, usize)->U, ) -> impl Draw { thunk(move|_to: &mut S|{ todo!() }) } pub fn iter_east <'a, S: Screen, D: 'a, I: Iterator, U: Draw> ( - _iter: impl Fn()->I, _draw: impl Fn(D)->U, + _iter: impl Fn()->I, _draw: impl Fn(D, usize)->U, ) -> impl Draw { thunk(move|_to: &mut S|{ todo!() }) } @@ -39,8 +39,7 @@ pub fn iter_south <'a, S: Screen, D: 'a, I: Iterator, U: Draw> ( } pub fn iter_west <'a, S: Screen, D: 'a, I: Iterator, U: Draw> ( - _iter: impl Fn()->I, _draw: impl Fn(D)->U, + _iter: impl Fn()->I, _draw: impl Fn(D, usize)->U, ) -> impl Draw { thunk(move|_to: &mut S|{ todo!() }) } - diff --git a/src/term/border.rs b/src/term/border.rs index 1fbd210..9a30995 100644 --- a/src/term/border.rs +++ b/src/term/border.rs @@ -5,7 +5,7 @@ use super::*; /// ``` /// /// TODO /// ``` -pub const fn border (on: bool, style: S, draw: impl Draw) -> impl Draw { +pub const fn border (on: bool, style: impl BorderStyle, draw: impl Draw) -> impl Draw { let content = wh_pad(1, 1, draw); let outline = when(on, thunk(move|to: &mut Tui|{ let XYWH(x, y, w, h) = to.1;