mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-05-04 07:40:15 +02:00
0.5.2: remove explicit lifetime bound from Map
This commit is contained in:
parent
829d35b61f
commit
86236b76cd
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -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",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[workspace.package]
|
||||
version = "0.5.1"
|
||||
version = "0.5.2"
|
||||
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue