diff --git a/src/action.rs b/src/action.rs index 90defeb..031f3b9 100644 --- a/src/action.rs +++ b/src/action.rs @@ -1,31 +1,31 @@ use color_eyre::Result; use std::marker::PhantomData; -pub trait Action<'a>: Send + 'a { - type Context: 'a; +pub trait Action: Send { + type Context; fn act(&self, ctx: &Self::Context) -> Result<()>; } -pub struct ClosureAction<'a, Context, F>(F, PhantomData<&'a Context>) +pub struct ClosureAction(F, PhantomData) where - F: Fn(&Context) -> Result<()> + Send + 'a, - Context: 'a + Sync; + F: Fn(&Context) -> Result<()> + Send, + Context: Sync; -impl<'a, Context, F> ClosureAction<'a, Context, F> +impl ClosureAction where - F: Fn(&Context) -> Result<()> + Send + 'a, - Context: 'a + Sync, + F: Fn(&Context) -> Result<()> + Send, + Context: Sync, { pub fn new(f: F) -> Self { Self(f, PhantomData) } } -impl<'a, Context, F> Action<'a> for ClosureAction<'a, Context, F> +impl Action for ClosureAction where - F: Fn(&Context) -> Result<()> + Send + 'a, - Context: 'a + Sync, + F: Fn(&Context) -> Result<()> + Send, + Context: Sync + Send, { type Context = Context; @@ -34,26 +34,24 @@ where } } -pub struct ActionWrapper<'a, ActionContext, ActionT, F, Cushion> +pub struct ActionWrapper where - F: Fn(&Cushion) -> ActionContext + Send + 'a, - ActionT: Action<'a, Context = ActionContext>, - ActionContext: 'a, - Cushion: 'a + Sync, + F: Fn(&Cushion) -> ActionContext + Send, + ActionT: Action, + Cushion: Sync, { f: F, action: ActionT, - _marker: PhantomData<&'a Cushion>, + _marker: PhantomData, } -impl<'a, ActionContext, ActionT, F, Cushion> Action<'a> - for ActionWrapper<'a, ActionContext, ActionT, F, Cushion> +impl Action + for ActionWrapper where - F: Fn(&Cushion) -> ActionContext + Send + 'a, - ActionT: Action<'a, Context = ActionContext>, - ActionContext: 'a, - Cushion: 'a + Sync, + F: Fn(&Cushion) -> ActionContext + Send, + ActionT: Action, + Cushion: Sync + Send, { type Context = Cushion; @@ -62,12 +60,11 @@ where } } -impl<'a, ActionContext, ActionT, F, Cushion> ActionWrapper<'a, ActionContext, ActionT, F, Cushion> +impl ActionWrapper where - F: Fn(&Cushion) -> ActionContext + Send + 'a, - ActionT: Action<'a, Context = ActionContext>, - ActionContext: 'a, - Cushion: 'a + Sync, + F: Fn(&Cushion) -> ActionContext + Send, + ActionT: Action, + Cushion: Sync, { pub fn new(action: ActionT, transformer: F) -> Self { Self { diff --git a/src/filter.rs b/src/filter.rs index d71edd3..74b5fbf 100644 --- a/src/filter.rs +++ b/src/filter.rs @@ -2,31 +2,29 @@ // 本当はasyncのほうがいいかも? use std::marker::PhantomData; -pub trait Filter<'a>: Send + 'a { - type Context: 'a; +pub trait Filter: Send { + type Context; fn predicate(&self, ctx: &Self::Context, input: &str) -> bool; } -pub struct ClosureFilter<'a, Context, F>(F, PhantomData<&'a Context>) +pub struct ClosureFilter(F, PhantomData) where - F: Fn(&Context, &str) -> bool, - Context: 'a; + F: Fn(&Context, &str) -> bool; -impl<'a, Context, F> ClosureFilter<'a, Context, F> +impl ClosureFilter where F: Fn(&Context, &str) -> bool, - Context: 'a, { pub fn new(f: F) -> Self { Self(f, PhantomData) } } -impl<'a, Context, F> Filter<'a> for ClosureFilter<'a, Context, F> +impl Filter for ClosureFilter where - F: Fn(&Context, &str) -> bool + Send + 'a, - Context: 'a + Sync, + F: Fn(&Context, &str) -> bool + Send, + Context: Sync + Send, { type Context = Context; @@ -35,25 +33,24 @@ where } } -pub struct FilterWrapper<'a, FilterContext, FilterT, F, Cushion> +pub struct FilterWrapper where - F: Fn(&Cushion) -> FilterContext + Send + 'a, - FilterT: Filter<'a, Context = FilterContext>, - FilterContext: 'a, + F: Fn(&Cushion) -> FilterContext + Send, + FilterT: Filter, { f: F, filter: FilterT, - _marker: PhantomData<(&'a FilterContext, Cushion)>, + _marker: PhantomData<(FilterContext, Cushion)>, } -impl<'a, FilterContext, FilterT, F, Cushion> Filter<'a> - for FilterWrapper<'a, FilterContext, FilterT, F, Cushion> +impl Filter + for FilterWrapper where - F: Fn(&Cushion) -> FilterContext + Send + 'a, - FilterT: Filter<'a, Context = FilterContext>, - FilterContext: 'a + Sync, - Cushion: 'a + Send, + F: Fn(&Cushion) -> FilterContext + Send, + FilterT: Filter, + FilterContext: Sync + Send, + Cushion: Send, { type Context = Cushion; @@ -62,12 +59,12 @@ where } } -impl<'a, FilterContext, FilterT, F, Cushion> FilterWrapper<'a, FilterContext, FilterT, F, Cushion> +impl FilterWrapper where - F: Fn(&Cushion) -> FilterContext + Send + 'a, - FilterT: Filter<'a, Context = FilterContext>, - FilterContext: 'a + Sync, - Cushion: 'a + Send, + F: Fn(&Cushion) -> FilterContext + Send, + FilterT: Filter, + FilterContext: Sync, + Cushion: Send, { pub fn new(filter: FilterT, transformer: F) -> Self { Self { diff --git a/src/launcher.rs b/src/launcher.rs index bff0ec3..af3640b 100644 --- a/src/launcher.rs +++ b/src/launcher.rs @@ -10,23 +10,23 @@ use crate::ui::UI; pub mod batcher; -pub struct Launcher<'a, Cushion, UIT, UIContext> +pub struct Launcher where - UIT: UI<'a, Context = UIContext>, - UIContext: 'a + Send, - Cushion: 'a + Sync, + UIT: UI, + UIContext: Send, + Cushion: Sync + Send, { - batcher: Batcher<'a, Cushion, UIContext>, + batcher: Batcher, - actions: Vec>>, + actions: Vec>>, ui: Option, } -impl<'a, Cushion, UIT, UIContext> Default for Launcher<'a, Cushion, UIT, UIContext> +impl Default for Launcher where - UIT: UI<'a, Context = UIContext> + 'a, - UIContext: 'a + Send, - Cushion: 'a + Sync, + UIT: UI, + UIContext: Send, + Cushion: Sync + Send, { fn default() -> Self { Self { @@ -49,41 +49,37 @@ where /// * `std::convert::Into::into` /// /// as the transformer function -impl<'a, Cushion, UIT, UIContext> Launcher<'a, Cushion, UIT, UIContext> +impl Launcher where - UIT: UI<'a, Context = UIContext> + Sync + 'a, - UIContext: 'a + Send, - Cushion: 'a + Send + Sync, + UIT: UI, + UIContext: Send, + Cushion: Send + Sync + 'static, { - pub fn add_source( - self, - source: Source<'a, SourceContext>, - transformer: F, - ) -> Self + pub fn add_source(self, source: Source, transformer: F) -> Self where - F: Fn(SourceContext) -> Cushion + Send + 'a, - SourceContext: 'a, + F: Fn(SourceContext) -> Cushion + Send + 'static, + SourceContext: 'static, { self.add_raw_source(transform_source(source, transformer)) } - pub fn add_raw_source(mut self, source: Source<'a, Cushion>) -> Self { + pub fn add_raw_source(mut self, source: Source) -> Self { self.batcher.add_raw_source(source); self } pub fn add_filter(self, filter: FilterT, transformer: F) -> Self where - F: Fn(&Cushion) -> FilterContext + Send + 'a, - FilterContext: 'a + Sync, - FilterT: Filter<'a, Context = FilterContext> + 'a, + FilterT: Filter + 'static, + FilterContext: Sync + Send + 'static, + F: Fn(&Cushion) -> FilterContext + Send + 'static, { self.add_raw_filter(FilterWrapper::new(filter, transformer)) } pub fn add_raw_filter(mut self, filter: FilterT) -> Self where - FilterT: Filter<'a, Context = Cushion> + 'a, + FilterT: Filter + 'static, { self.batcher.add_raw_filter(filter); self @@ -91,35 +87,36 @@ where pub fn add_sorter(self, sorter: SorterT, transformer: F) -> Self where - F: Fn(&Cushion) -> SorterContext + Send + 'a, - SorterContext: 'a + Sync, - SorterT: Sorter<'a, Context = SorterContext> + 'a, - Cushion: 'a + Send, + SorterT: Sorter + 'static, + SorterContext: Sync + Send + 'static, + F: Fn(&Cushion) -> SorterContext + Send + 'static, { self.add_raw_sorter(SorterWrapper::new(sorter, transformer)) } pub fn add_raw_sorter(mut self, sorter: SorterT) -> Self where - SorterT: Sorter<'a, Context = Cushion> + 'a, + SorterT: Sorter + 'static, { self.batcher.add_raw_sorter(sorter); self } - pub fn add_action(self, action: ActionT, transformer: F) -> Self + pub fn add_action( + self, + action: ActionT, + transformer: F, + ) -> Self where - F: Fn(&Cushion) -> ActionContext + Send + 'a, - ActionT: Action<'a, Context = ActionContext> + 'a, - ActionContext: 'a, - Cushion: 'a + Sync, + ActionT: Action + 'static, + F: Fn(&Cushion) -> ActionContext + Send + 'static, { self.add_raw_action(ActionWrapper::new(action, transformer)) } pub fn add_raw_action(mut self, action: ActionT) -> Self where - ActionT: Action<'a, Context = Cushion> + 'a, + ActionT: Action + 'static, { self.actions.push(Box::new(action)); @@ -128,41 +125,40 @@ where pub fn set_ui(mut self, ui: UIT, transformer: F) -> Self where - F: Fn(&Cushion) -> UIContext + Send + Sync + 'a, + F: Fn(&Cushion) -> UIContext + Send + Sync + 'static, { self.ui = Some(ui); - self.batcher.cusion_to_ui = Some(Box::new(transformer)); + self.batcher.cushion_to_ui = Some(Box::new(transformer)); self } pub fn add_generator(self, generator: GenT, transformer: F) -> Self where - Item: 'a, - F: Fn(Item) -> Cushion + Sync + Send + 'a, - GenT: Generator + Sync + Send + 'a, - Cushion: Sync + 'a, + GenT: Generator + Sync + Send + 'static, + Item: 'static, + F: Fn(Item) -> Cushion + Sync + Send + 'static, { self.add_raw_generator(GenWrapper::new(generator, transformer)) } pub fn add_raw_generator(mut self, generator: GenT) -> Self where - GenT: Generator + Sync + Send + 'a, + GenT: Generator + Sync + Send + 'static, { self.batcher.add_raw_generator(generator); self } pub async fn run(self) -> Result<()> { - let cusion: Option = self + let cushion: Option = self .ui .ok_or_eyre("UI must be set before calling run")? .run(self.batcher) .await?; - if let Some(cusion) = cusion { + if let Some(cushion) = cushion { for ai in self.actions { - ai.act(&cusion)?; + ai.act(&cushion)?; } } @@ -171,7 +167,7 @@ where /// If `filter_and` is true and more than one filter is provided, /// the launcher will display only entries that satisfy all filter predicates. - /// The default value is false. + /// The default value is true. pub fn filter_and(mut self, flag: bool) -> Self { self.batcher.filter_and = flag; self diff --git a/src/launcher/batcher.rs b/src/launcher/batcher.rs index c30b682..2ee9135 100644 --- a/src/launcher/batcher.rs +++ b/src/launcher/batcher.rs @@ -11,19 +11,19 @@ use crate::ui::{Buffer, Position}; use tokio_stream::StreamExt as _; -type CushionToUIF<'a, Cushion, UIContext> = Option UIContext + Send + 'a>>; +type CushionToUIF = Option UIContext + Send>>; -type FilterT<'a, Cushion> = Box>; -type SorterT<'a, Cushion> = Box>; -type GenT<'a, Cushion> = Box + 'a>; +type FilterT = Box>; +type SorterT = Box>; +type GenT = Box>; -pub struct Batcher<'a, Cushion, UIContext> { - filters: Vec>, - sorters: Vec>, - generators: Vec>, - sources: Vec>, +pub struct Batcher { + filters: Vec>, + sorters: Vec>, + generators: Vec>, + sources: Vec>, - pub(super) cusion_to_ui: CushionToUIF<'a, Cushion, UIContext>, + pub(super) cushion_to_ui: CushionToUIF, pub(super) batch_size: usize, pub(super) filter_and: bool, @@ -31,9 +31,9 @@ pub struct Batcher<'a, Cushion, UIContext> { state: BatcherState, } -impl<'a, Cushion, UIContext> Default for Batcher<'a, Cushion, UIContext> +impl Default for Batcher where - UIContext: 'a + Send, + UIContext: Send, { fn default() -> Self { Self { @@ -45,7 +45,7 @@ where batch_size: 0, filter_and: true, - cusion_to_ui: None, + cushion_to_ui: None, state: BatcherState::default(), } @@ -115,15 +115,15 @@ impl Default for BatcherState { } } -impl<'a, Cushion, UIContext> Batcher<'a, Cushion, UIContext> +impl Batcher where - Cushion: std::marker::Send + 'a, + Cushion: Send, { /// Consumes (and destroys) the current instance, returning ownership of the `Cushion`. /// /// Call this function as the final step to retrieve the `Cushion`. #[inline(always)] - pub fn compute_cusion(mut self, id: usize) -> Result { + pub fn compute_cushion(mut self, id: usize) -> Result { ensure!( self.state.items.len() > id, "Failed to get Cushion, index is over the length. Maybe the ui is not using the usize obtained from Buffer" @@ -135,25 +135,25 @@ where #[inline(always)] fn create_sorter(&self) -> impl Fn(&usize, &usize) -> std::cmp::Ordering { |lhs, rhs| { - use std::cmp::Ordering::*; + use std::cmp::Ordering; let lhs = &self.state.items[*lhs]; let rhs = &self.state.items[*rhs]; for si in &self.sorters { match si.compare(lhs, rhs, &self.state.input) { - Equal => { + Ordering::Equal => { continue; } ord => return ord, } } - Equal + Ordering::Equal } } // ここのusizeはself.state.itemsのindex - // あとからmergeで比較しつつmergeして、最後にcusion_to_uiで(UIContext, usize)に変換される + // あとからmergeで比較しつつmergeして、最後にcushion_to_uiで(UIContext, usize)に変換される /// Prepares the next batch of indices for rendering. /// @@ -195,23 +195,23 @@ where // Iterator>> // でjoin_allでFutureを解決して - let cusions_from_gen = self.generators + let cushions_from_gen = self.generators [self.state.gen_index..(self.state.gen_index + gen_count_to_run)] .iter() .map(|r#gen| async { - let cusions = r#gen.generate(&self.state.input).await.into_iter(); + let cushions = r#gen.generate(&self.state.input).await.into_iter(); // 最終結果で計算が終わったあとの長さにしか興味がないからRelaxedで問題ない - len.fetch_add(cusions.len(), Ordering::Relaxed); - cusions + len.fetch_add(cushions.len(), Ordering::Relaxed); + cushions }); - let cusions_from_gen = futures::future::join_all(cusions_from_gen) + let cushions_from_gen = futures::future::join_all(cushions_from_gen) .await .into_iter() .flatten(); v.reserve(len.load(Ordering::SeqCst)); - for c in cusions_from_gen { + for c in cushions_from_gen { let index = self.state.items.len(); self.state.items.push(c); v.push(index); @@ -236,9 +236,9 @@ where { v.push(*ci); } else if self.state.source_index < self.sources.len() { - if let Some(cusion) = self.state.peeked_item.take() { + if let Some(cushion) = self.state.peeked_item.take() { batch_count -= 1; - self.state.items.push(cusion); + self.state.items.push(cushion); v.push(self.state.items.len() - 1); self.state .items_from_sources_i @@ -302,7 +302,7 @@ where mut from: Buffer, ) -> Result { ensure!( - self.cusion_to_ui.is_some(), + self.cushion_to_ui.is_some(), "Cushion to UIContext did not set. Did you set UI?(This error is probably not called because of the way Rust works!)" ); debug!("state on merge: {:?}", self.state); @@ -332,7 +332,7 @@ where next_dst = iter_dst.next(); } else { merged.push({ - let ui_ctx = (self.cusion_to_ui.as_ref().unwrap())( + let ui_ctx = (self.cushion_to_ui.as_ref().unwrap())( &self.state.items[*next_src.unwrap()], ); @@ -348,12 +348,12 @@ where } if let Some(val) = next_src { merged.push({ - let ui_ctx = (self.cusion_to_ui.as_ref().unwrap())(&self.state.items[*val]); + let ui_ctx = (self.cushion_to_ui.as_ref().unwrap())(&self.state.items[*val]); (ui_ctx, *val) }); merged.extend(iter_src.map(|ci| { - let ui_ctx = (self.cusion_to_ui.as_ref().unwrap())(&self.state.items[*ci]); + let ui_ctx = (self.cushion_to_ui.as_ref().unwrap())(&self.state.items[*ci]); (ui_ctx, *ci) })); @@ -377,27 +377,27 @@ where // そういえばSourceだけもともとBoxを求めてる(まあいいや) /// Add a source to `self`, builder - pub(super) fn add_raw_source(&mut self, source: Source<'a, Cushion>) { + pub(super) fn add_raw_source(&mut self, source: Source) { self.sources.push(source); } pub(super) fn add_raw_filter(&mut self, filter: FilterT) where - FilterT: Filter<'a, Context = Cushion> + 'a, + FilterT: Filter + 'static, { self.filters.push(Box::new(filter)); } pub(super) fn add_raw_sorter(&mut self, sorter: SorterT) where - SorterT: Sorter<'a, Context = Cushion> + 'a, + SorterT: Sorter + 'static, { self.sorters.push(Box::new(sorter)); } pub(super) fn add_raw_generator(&mut self, generator: GenT) where - GenT: Generator + Sync + Send + 'a, + GenT: Generator + Sync + Send + 'static, { self.generators.push(Box::new(generator)); } @@ -409,7 +409,7 @@ mod tests { #[test] fn add_source() -> Result<(), Box> { - let mut batcher: Batcher<'_, i32, ()> = Batcher::default(); + let mut batcher: Batcher = Batcher::default(); batcher.add_raw_source(Box::pin(tokio_stream::iter(vec![1, 2]))); @@ -420,7 +420,7 @@ mod tests { #[test] fn add_filter() -> Result<(), Box> { - let mut batcher: Batcher<'_, i32, ()> = Batcher::default(); + let mut batcher: Batcher = Batcher::default(); batcher.add_raw_filter(crate::filter::ClosureFilter::new(|&x: &i32, input| { x == 0i32 && input == "" @@ -433,7 +433,7 @@ mod tests { #[test] fn add_sorter() -> Result<(), Box> { - let mut batcher: Batcher<'_, i32, ()> = Batcher::default(); + let mut batcher: Batcher = Batcher::default(); batcher.add_raw_sorter(crate::sorter::ClosureSorter::new(|lhs: &i32, rhs, _| { lhs.cmp(rhs) @@ -446,7 +446,7 @@ mod tests { #[test] fn add_generator() -> Result<(), Box> { - let mut batcher: Batcher<'_, (), ()> = Batcher::default(); + let mut batcher: Batcher<(), ()> = Batcher::default(); batcher.add_raw_generator(crate::generator::ClosureGenerator::new(|input| { println!("{input}"); vec![] @@ -459,7 +459,7 @@ mod tests { #[tokio::test] async fn test_prepare() -> Result<(), Box> { - let mut batcher: Batcher<'_, i32, ()> = Batcher::default(); + let mut batcher: Batcher = Batcher::default(); batcher.add_raw_source(Box::pin(tokio_stream::iter(vec![1, 2]))); diff --git a/src/sorter.rs b/src/sorter.rs index d5c3939..fbd5291 100644 --- a/src/sorter.rs +++ b/src/sorter.rs @@ -1,30 +1,28 @@ use std::marker::PhantomData; -pub trait Sorter<'a>: Send + 'a { - type Context: 'a; +pub trait Sorter: Send { + type Context; fn compare(&self, lhs: &Self::Context, rhs: &Self::Context, input: &str) -> std::cmp::Ordering; } -pub struct ClosureSorter<'a, Context, F>(F, PhantomData<&'a Context>) +pub struct ClosureSorter(F, PhantomData) where - F: Fn(&Context, &Context, &str) -> std::cmp::Ordering, - Context: 'a; + F: Fn(&Context, &Context, &str) -> std::cmp::Ordering; -impl<'a, Context, F> ClosureSorter<'a, Context, F> +impl ClosureSorter where F: Fn(&Context, &Context, &str) -> std::cmp::Ordering, - Context: 'a, { pub fn new(f: F) -> Self { Self(f, PhantomData) } } -impl<'a, Context, F> Sorter<'a> for ClosureSorter<'a, Context, F> +impl Sorter for ClosureSorter where - F: Fn(&Context, &Context, &str) -> std::cmp::Ordering + Send + 'a, - Context: 'a + Sync, + F: Fn(&Context, &Context, &str) -> std::cmp::Ordering + Send, + Context: Sync + Send, { type Context = Context; @@ -33,25 +31,25 @@ where } } -pub struct SorterWrapper<'a, SorterContext, SorterT, F, Cushion> +pub struct SorterWrapper where - F: Fn(&Cushion) -> SorterContext + Send + 'a, - SorterT: Sorter<'a, Context = SorterContext>, - SorterContext: 'a + Sync, + F: Fn(&Cushion) -> SorterContext + Send, + SorterT: Sorter, + SorterContext: Sync, { f: F, sorter: SorterT, - _marker: PhantomData<(&'a SorterContext, Cushion)>, + _marker: PhantomData<(SorterContext, Cushion)>, } -impl<'a, SorterContext, SorterT, F, Cushion> Sorter<'a> - for SorterWrapper<'a, SorterContext, SorterT, F, Cushion> +impl Sorter + for SorterWrapper where - F: Fn(&Cushion) -> SorterContext + Send + 'a, - SorterT: Sorter<'a, Context = SorterContext>, - SorterContext: 'a + Sync, - Cushion: 'a + Send, + F: Fn(&Cushion) -> SorterContext + Send, + SorterT: Sorter, + SorterContext: Sync + Send, + Cushion: Send, { type Context = Cushion; @@ -60,12 +58,12 @@ where } } -impl<'a, SorterContext, SorterT, F, Cushion> SorterWrapper<'a, SorterContext, SorterT, F, Cushion> +impl SorterWrapper where - F: Fn(&Cushion) -> SorterContext + Send + 'a, - SorterT: Sorter<'a, Context = SorterContext>, - SorterContext: 'a + Sync, - Cushion: 'a + Send, + F: Fn(&Cushion) -> SorterContext + Send, + SorterT: Sorter, + SorterContext: Sync, + Cushion: Send, { pub fn new(sorter: SorterT, transformer: F) -> Self { Self { diff --git a/src/source.rs b/src/source.rs index 88c049a..2affa0c 100644 --- a/src/source.rs +++ b/src/source.rs @@ -1,23 +1,23 @@ use std::pin::Pin; -pub type Source<'a, T> = Pin + Send + 'a>>; +pub type Source = Pin + Send>>; -pub fn from_iter<'a, T, Iter>( +pub fn from_iter( iter: impl std::iter::IntoIterator, -) -> Source<'a, T> +) -> Source where - Iter: std::iter::Iterator + Send + 'a, + Iter: std::iter::Iterator + Send + 'static, { Box::pin(tokio_stream::iter(iter)) } -pub fn transform_source<'a, Cushion, SourceContext, F>( - source: Source<'a, SourceContext>, +pub fn transform_source( + source: Source, f: F, -) -> Source<'a, Cushion> +) -> Source where - SourceContext: 'a, - F: Fn(SourceContext) -> Cushion + Send + 'a, + SourceContext: 'static, + F: Fn(SourceContext) -> Cushion + Send + 'static, { use tokio_stream::StreamExt as _; diff --git a/src/ui.rs b/src/ui.rs index 1e45e70..d094398 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -1,11 +1,11 @@ use color_eyre::Result; -pub trait UI<'a> { - type Context: 'a; +pub trait UI { + type Context; - fn run( + fn run( &self, - batcher: crate::launcher::batcher::Batcher<'a, Cushion, Self::Context>, + batcher: crate::launcher::batcher::Batcher, ) -> impl std::future::Future>> + Send; } diff --git a/tests/dummyui.rs b/tests/dummyui.rs index e4cedb1..605d533 100644 --- a/tests/dummyui.rs +++ b/tests/dummyui.rs @@ -7,19 +7,18 @@ use ltrait::{ use std::marker::PhantomData; -pub struct DummyUI<'a, T, F> +pub struct DummyUI where - T: 'a, F: Fn(&T), { f: F, - _marker: PhantomData<&'a T>, + _marker: PhantomData, } -impl<'a, T, F> DummyUI<'a, T, F> +impl DummyUI where - T: 'a + Sync + Send, + T: Sync + Send, F: Fn(&T) + Sync, { pub fn new(f: F) -> Self { @@ -30,17 +29,17 @@ where } } -impl<'a, T, F> UI<'a> for DummyUI<'a, T, F> +impl UI for DummyUI where - T: 'a + Sync + Send, + T: Sync + Send, F: Fn(&T) + Sync, { type Context = T; - async fn run( + async fn run( &self, - mut batcher: Batcher<'a, Cusion, Self::Context>, - ) -> Result> { + mut batcher: Batcher, + ) -> Result> { let mut more = true; let mut buf: Buffer<(T, usize)> = Buffer::default(); @@ -59,7 +58,7 @@ where } if least_one { - Ok(Some(batcher.compute_cusion(0)?)) + Ok(Some(batcher.compute_cushion(0)?)) } else { Ok(None) }