Skip to content

Commit 61fa067

Browse files
authored
Merge pull request #30 from ltrait/push-mstqmqtmtyts
feat: restricted UI bound
2 parents 088cc4d + 8924091 commit 61fa067

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

src/launcher.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ pub mod batcher;
1212

1313
pub struct Launcher<Cushion, UIT, UIContext>
1414
where
15-
UIT: UI<Context = UIContext>,
15+
UIT: UI<Cushion, Context = UIContext>,
1616
UIContext: Send,
17-
Cushion: Sync + Send,
17+
Cushion: Sync + Send + 'static,
1818
{
1919
batcher: Batcher<Cushion, UIContext>,
2020

@@ -24,7 +24,7 @@ where
2424

2525
impl<Cushion, UIT, UIContext> Default for Launcher<Cushion, UIT, UIContext>
2626
where
27-
UIT: UI<Context = UIContext>,
27+
UIT: UI<Cushion, Context = UIContext>,
2828
UIContext: Send,
2929
Cushion: Sync + Send,
3030
{
@@ -51,7 +51,7 @@ where
5151
/// as the transformer function
5252
impl<Cushion, UIT, UIContext> Launcher<Cushion, UIT, UIContext>
5353
where
54-
UIT: UI<Context = UIContext>,
54+
UIT: UI<Cushion, Context = UIContext>,
5555
UIContext: Send,
5656
Cushion: Send + Sync + 'static,
5757
{

src/ui.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use color_eyre::Result;
22

3-
pub trait UI {
3+
pub trait UI<Cushion: Send + Sync + 'static> {
44
type Context;
55

6-
fn run<Cushion: Send>(
6+
fn run(
77
&self,
88
batcher: crate::launcher::batcher::Batcher<Cushion, Self::Context>,
99
) -> impl std::future::Future<Output = Result<Option<Cushion>>> + Send;

tests/dummyui.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,15 @@ where
2929
}
3030
}
3131

32-
impl<T, F> UI for DummyUI<T, F>
32+
impl<T, F, Cushion> UI<Cushion> for DummyUI<T, F>
3333
where
3434
T: Sync + Send,
3535
F: Fn(&T) + Sync,
36+
Cushion: Send + Sync + 'static,
3637
{
3738
type Context = T;
3839

39-
async fn run<Cushion: Send>(
40-
&self,
41-
mut batcher: Batcher<Cushion, Self::Context>,
42-
) -> Result<Option<Cushion>> {
40+
async fn run(&self, mut batcher: Batcher<Cushion, Self::Context>) -> Result<Option<Cushion>> {
4341
let mut more = true;
4442
let mut buf: Buffer<(T, usize)> = Buffer::default();
4543

0 commit comments

Comments
 (0)