mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 11:46:42 +01:00
0.5.2: remove explicit lifetime bound from Map
This commit is contained in:
parent
829d35b61f
commit
86236b76cd
3 changed files with 26 additions and 53 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
|
@ -934,7 +934,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tengri"
|
name = "tengri"
|
||||||
version = "0.5.1"
|
version = "0.5.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"tengri_dsl",
|
"tengri_dsl",
|
||||||
"tengri_input",
|
"tengri_input",
|
||||||
|
|
@ -944,7 +944,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tengri_dsl"
|
name = "tengri_dsl"
|
||||||
version = "0.5.1"
|
version = "0.5.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itertools 0.14.0",
|
"itertools 0.14.0",
|
||||||
"konst",
|
"konst",
|
||||||
|
|
@ -955,7 +955,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tengri_input"
|
name = "tengri_input"
|
||||||
version = "0.5.1"
|
version = "0.5.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"tengri_dsl",
|
"tengri_dsl",
|
||||||
"tengri_tui",
|
"tengri_tui",
|
||||||
|
|
@ -963,7 +963,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tengri_output"
|
name = "tengri_output"
|
||||||
version = "0.5.1"
|
version = "0.5.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proptest",
|
"proptest",
|
||||||
"proptest-derive",
|
"proptest-derive",
|
||||||
|
|
@ -974,7 +974,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tengri_tui"
|
name = "tengri_tui"
|
||||||
version = "0.5.1"
|
version = "0.5.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atomic_float",
|
"atomic_float",
|
||||||
"better-panic",
|
"better-panic",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.5.1"
|
version = "0.5.2"
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
|
||||||
|
|
@ -23,24 +23,21 @@ use crate::*;
|
||||||
Push::x(item_offset, Align::w(Fixed::x(item_width, Fill::y(item))))
|
Push::x(item_offset, Align::w(Fixed::x(item_width, Fill::y(item))))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Map<
|
/// Renders items from an iterator.
|
||||||
'a,
|
pub struct Map<E, A, B, I, F, G>
|
||||||
E,
|
where
|
||||||
A,
|
|
||||||
B,
|
|
||||||
I: Iterator<Item = A> + Send + Sync,
|
I: Iterator<Item = A> + Send + Sync,
|
||||||
F: Fn() -> I + Send + Sync + 'a,
|
F: Fn() -> I + Send + Sync,
|
||||||
G,
|
{
|
||||||
> {
|
__: PhantomData<(E, B)>,
|
||||||
__: PhantomData<&'a (E, B)>,
|
|
||||||
/// Function that returns iterator over stacked components
|
/// Function that returns iterator over stacked components
|
||||||
get_iterator: F,
|
get_iterator: F,
|
||||||
/// Function that returns each stacked component
|
/// Function that returns each stacked component
|
||||||
get_item: G,
|
get_item: G,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, E, A, B, I, F, G> Map<'a, E, A, B, I, F, G> where
|
impl<'a, E, A, B, I, F, G> Map<E, A, B, I, F, G> where
|
||||||
I: Iterator<Item = A> + Send + Sync,
|
I: Iterator<Item = A> + Send + Sync + 'a,
|
||||||
F: Fn() -> I + Send + Sync + 'a,
|
F: Fn() -> I + Send + Sync + 'a,
|
||||||
{
|
{
|
||||||
pub fn new (get_iterator: F, get_item: G) -> Self {
|
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
|
impl<'a, E, A, B, I, F, G> Content<E> for Map<E, A, B, I, F, G> 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
|
|
||||||
E: Output,
|
E: Output,
|
||||||
B: Render<E>,
|
B: Render<E>,
|
||||||
I: Iterator<Item = A> + Send + Sync,
|
I: Iterator<Item = A> + Send + Sync + 'a,
|
||||||
F: Fn() -> I + Send + Sync + 'a,
|
F: Fn() -> I + Send + Sync + 'a,
|
||||||
G: Fn(A, usize)->B + Send + Sync
|
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…
Add table
Add a link
Reference in a new issue