Skip to content

Commit 1819de6

Browse files
committed
feat: restricted UI bound
1 parent 088cc4d commit 1819de6

File tree

4 files changed

+14
-16
lines changed

4 files changed

+14
-16
lines changed

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ tracing-subscriber = { version = "0.3.19", features = [
3030
[dev-dependencies]
3131
async-stream = "0.3.6"
3232
tokio = { version = "1.43.0", features = ["full"] }
33-
criterion = { version = "4.0.4", package = "codspeed-criterion-compat", features = [
34-
"async",
35-
"async_tokio",
36-
"tokio",
37-
] }
33+
# criterion = { version = "4.0.4", package = "codspeed-criterion-compat", features = [
34+
# "async",
35+
# "async_tokio",
36+
# "tokio",
37+
# ] }
3838

3939
[features]
4040
default = ["log"]

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)