0.5.2: remove explicit lifetime bound from Map

This commit is contained in:
🪞👃🪞 2025-04-04 01:49:51 +03:00
parent 829d35b61f
commit 86236b76cd
3 changed files with 26 additions and 53 deletions

View file

@ -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<E, A, B, I, F, G>
where
I: Iterator<Item = A> + 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<Item = A> + Send + Sync,
impl<'a, E, A, B, I, F, G> Map<E, A, B, I, F, G> where
I: Iterator<Item = A> + 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<E>,
//I: Iterator<Item = A> + Send + Sync,
//F: Fn() -> I + Send + Sync + 'a,
//{
//pub fn south <G> (
//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<E::Unit, Align<Fixed<E::Unit, Fill<B>>>> + 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 <G> (
//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<E::Unit, Align<Fixed<E::Unit, Fill<B>>>> + 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<E> for Map<'a, E, A, B, I, F, G> where
impl<'a, E, A, B, I, F, G> Content<E> for Map<E, A, B, I, F, G> where
E: Output,
B: Render<E>,
I: Iterator<Item = A> + Send + Sync,
I: Iterator<Item = A> + 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<E> for Map<'a, E, A, B, I, F, G> where
}
}
}
#[cfg(test)] #[test] fn test_iter_map () {
struct Foo;
impl<T: Output> Content<T> for Foo {}
fn make_map <T: Output, U: Content<T> + Send + Sync> (data: &Vec<U>) -> impl Content<T> {
Map::new(||data.iter(), |foo, index|{})
}
let data = vec![Foo, Foo, Foo];
//let map = make_map(&data);
}