diff --git a/Cargo.lock b/Cargo.lock index 7308d24..3972207 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -934,7 +934,7 @@ dependencies = [ [[package]] name = "tengri" -version = "0.5.1" +version = "0.5.2" dependencies = [ "tengri_dsl", "tengri_input", @@ -944,7 +944,7 @@ dependencies = [ [[package]] name = "tengri_dsl" -version = "0.5.1" +version = "0.5.2" dependencies = [ "itertools 0.14.0", "konst", @@ -955,7 +955,7 @@ dependencies = [ [[package]] name = "tengri_input" -version = "0.5.1" +version = "0.5.2" dependencies = [ "tengri_dsl", "tengri_tui", @@ -963,7 +963,7 @@ dependencies = [ [[package]] name = "tengri_output" -version = "0.5.1" +version = "0.5.2" dependencies = [ "proptest", "proptest-derive", @@ -974,7 +974,7 @@ dependencies = [ [[package]] name = "tengri_tui" -version = "0.5.1" +version = "0.5.2" dependencies = [ "atomic_float", "better-panic", diff --git a/Cargo.toml b/Cargo.toml index c18d92a..d075434 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "0.5.1" +version = "0.5.2" [workspace] resolver = "2" diff --git a/output/src/op_iter.rs b/output/src/op_iter.rs index 639812b..c1f2796 100644 --- a/output/src/op_iter.rs +++ b/output/src/op_iter.rs @@ -23,24 +23,21 @@ use crate::*; Push::x(item_offset, Align::w(Fixed::x(item_width, Fill::y(item)))) } -pub struct Map< - 'a, - E, - A, - B, +/// Renders items from an iterator. +pub struct Map +where I: Iterator + Send + Sync, - F: Fn() -> I + Send + Sync + 'a, - G, -> { - __: PhantomData<&'a (E, B)>, + F: Fn() -> I + Send + Sync, +{ + __: PhantomData<(E, B)>, /// Function that returns iterator over stacked components get_iterator: F, /// Function that returns each stacked component get_item: G, } -impl<'a, E, A, B, I, F, G> Map<'a, E, A, B, I, F, G> where - I: Iterator + Send + Sync, +impl<'a, E, A, B, I, F, G> Map where + I: Iterator + Send + Sync + 'a, F: Fn() -> I + Send + Sync + 'a, { pub fn new (get_iterator: F, get_item: G) -> Self { @@ -52,44 +49,10 @@ impl<'a, E, A, B, I, F, G> Map<'a, E, A, B, I, F, G> where } } -//impl<'a, E, A, B, I, F> Map<'a, E, A, B, I, F, ()> where - //E: Output, - //B: Content, - //I: Iterator + Send + Sync, - //F: Fn() -> I + Send + Sync + 'a, -//{ - //pub fn south ( - //get_iterator: F, - //get_content: impl Fn(A, usize)->B + Send + Sync, - //) -> Map<'a, E, A, B, I, F, G> where - //G: Fn(A, usize)->Push>>> + Send + Sync - //{ - //let mut offset = 0; - //Map::new(get_iterator, move|item, index|map_south( - //0.into(), - //0.into(), - //get_content(item, index) - //)) - //} - //pub fn east ( - //get_iterator: F, - //get_content: impl Fn(A, usize)->B + Send + Sync, - //) -> Map<'a, E, A, B, I, F, G> where - //G: Fn(A, usize)->Push>>> + Send + Sync - //{ - //let mut offset = 0; - //Map::new(get_iterator, move|item, index|map_east( - //0.into(), - //0.into(), - //get_content(item, index) - //)) - //} -//} - -impl<'a, E, A, B, I, F, G> Content for Map<'a, E, A, B, I, F, G> where +impl<'a, E, A, B, I, F, G> Content for Map where E: Output, B: Render, - I: Iterator + Send + Sync, + I: Iterator + Send + Sync + 'a, F: Fn() -> I + Send + Sync + 'a, G: Fn(A, usize)->B + Send + Sync { @@ -123,3 +86,13 @@ impl<'a, E, A, B, I, F, G> Content for Map<'a, E, A, B, I, F, G> where } } } + +#[cfg(test)] #[test] fn test_iter_map () { + struct Foo; + impl Content for Foo {} + fn make_map + Send + Sync> (data: &Vec) -> impl Content { + Map::new(||data.iter(), |foo, index|{}) + } + let data = vec![Foo, Foo, Foo]; + //let map = make_map(&data); +}