Skip to content

Commit 6b8d91f

Browse files
committed
Fix build by adding trait bounds to existential types
Fix hydro-project#150 rust-lang/rust#96899
1 parent 77ebfc3 commit 6b8d91f

File tree

11 files changed

+34
-13
lines changed

11 files changed

+34
-13
lines changed

hydroflow/src/builder/build/pull_filter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ where
2323
type PullBuildImpl<'slf, 'ctx, Prev, Func>
2424
where
2525
Prev: PullBuild,
26-
Func: 'slf,
26+
Func: 'slf + FnMut(&Context, &Prev::ItemOut) -> bool,
2727
= std::iter::Filter<Prev::Build<'slf, 'ctx>, impl FnMut(&Prev::ItemOut) -> bool>;
2828

2929
impl<Prev, Func> PullBuild for FilterPullBuild<Prev, Func>

hydroflow/src/builder/build/pull_filter_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ where
2323
type PullBuildImpl<'slf, 'ctx, Prev, Func, Out>
2424
where
2525
Prev: PullBuild,
26-
Func: 'slf,
26+
Func: 'slf + FnMut(&Context, Prev::ItemOut) -> Option<Out>,
2727
= std::iter::FilterMap<Prev::Build<'slf, 'ctx>, impl FnMut(Prev::ItemOut) -> Option<Out>>;
2828

2929
impl<Prev, Func, Out> PullBuild for FilterMapPullBuild<Prev, Func>

hydroflow/src/builder/build/pull_fold_epoch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ where
2525
type PullBuildImpl<'slf, 'ctx, Prev, Init, Func, Out>
2626
where
2727
Prev: 'slf + PullBuild,
28-
Init: 'slf,
29-
Func: 'slf,
28+
Init: 'slf + FnMut(&Context) -> Out,
29+
Func: 'slf + FnMut(&Context, Out, Prev::ItemOut) -> Out,
3030
= std::iter::OnceWith<impl FnOnce() -> Out>;
3131

3232
impl<Prev, Init, Func, Out> PullBuild for FoldEpochPullBuild<Prev, Init, Func>

hydroflow/src/builder/build/pull_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ where
2323
type PullBuildImpl<'slf, 'ctx, Prev, Func, Out>
2424
where
2525
Prev: PullBuild,
26-
Func: 'slf,
26+
Func: 'slf + FnMut(&Context, Prev::ItemOut) -> Out,
2727
= std::iter::Map<Prev::Build<'slf, 'ctx>, impl FnMut(Prev::ItemOut) -> Out>;
2828

2929
impl<Prev, Func, Out> PullBuild for MapPullBuild<Prev, Func>

hydroflow/src/builder/build/push_filter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ where
2727
type PushBuildImpl<'slf, 'ctx, Next, Func>
2828
where
2929
Next: PushBuild,
30-
Func: 'slf,
30+
Func: 'slf + FnMut(&Context, &Next::ItemIn) -> bool,
3131
= Filter<Next::ItemIn, impl FnMut(&Next::ItemIn) -> bool, Next::Build<'slf, 'ctx>>;
3232

3333
impl<Next, Func> PushBuild for FilterPushBuild<Next, Func>

hydroflow/src/builder/build/push_filter_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ where
3434
type PushBuildImpl<'slf, 'ctx, Next, Func, In>
3535
where
3636
Next: PushBuild,
37-
Func: 'slf,
37+
Func: 'slf + FnMut(&Context, In) -> Option<Next::ItemIn>,
3838
= FilterMap<Next::Build<'slf, 'ctx>, impl FnMut(In) -> Option<Next::ItemIn>, In>;
3939

4040
impl<Next, Func, In> PushBuild for FilterMapPushBuild<Next, Func, In>

hydroflow/src/builder/build/push_for_each.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ where
3030
#[allow(type_alias_bounds)]
3131
type PushBuildImpl<'slf, 'ctx, Func, In>
3232
where
33-
Func: 'slf,
33+
Func: 'slf + FnMut(&Context, In),
3434
= ForEach<In, impl FnMut(In)>;
3535

3636
impl<Func, In> PushBuild for ForEachPushBuild<Func, In>

hydroflow/src/builder/build/push_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ where
3434
type PushBuildImpl<'slf, 'ctx, Next, Func, In>
3535
where
3636
Next: PushBuild,
37-
Func: 'slf,
37+
Func: 'slf + FnMut(&Context, In) -> Next::ItemIn,
3838
= Map<In, Next::ItemIn, impl FnMut(In) -> Next::ItemIn, Next::Build<'slf, 'ctx>>;
3939

4040
impl<Next, Func, In> PushBuild for MapPushBuild<Next, Func, In>

hydroflow/src/builder/build/push_partition.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@ where
4242
#[allow(type_alias_bounds)]
4343
type PushBuildImpl<'slf, 'ctx, NextA, NextB, Func>
4444
where
45+
Func: 'slf + FnMut(&Context, &NextA::ItemIn) -> bool,
4546
NextA: PushBuild,
4647
NextB: PushBuild<ItemIn = NextA::ItemIn>,
47-
Func: 'slf,
48+
49+
NextA::OutputHandoffs: Extend<NextB::OutputHandoffs>,
50+
<NextA::OutputHandoffs as Extend<NextB::OutputHandoffs>>::Extended:
51+
PortList<SEND> + PortListSplit<SEND, NextA::OutputHandoffs, Suffix = NextB::OutputHandoffs>,
4852
= Partition<
4953
NextA::ItemIn,
5054
impl FnMut(&NextA::ItemIn) -> bool,

hydroflow/src/builder/surface/map_scan.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ use crate::scheduled::context::Context;
1010
use crate::scheduled::flow_graph::NodeId;
1111
use crate::scheduled::state::StateHandle;
1212

13-
type MapScanFunc<Func, State, In, Out> = impl FnMut(&Context, In) -> Out;
13+
type MapScanFunc<Func, State, In, Out>
14+
where
15+
Func: FnMut(&mut State, In) -> Out,
16+
State: Any,
17+
= impl FnMut(&Context, In) -> Out;
1418

1519
fn wrap_func<Func, State, In, Out>(
1620
mut func: Func,

hydroflow/src/builder/surface/mod.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,26 +190,31 @@ pub trait BaseSurface {
190190
pub type MapNoCtxFn<Prev, Func, Out>
191191
where
192192
Prev: BaseSurface,
193+
Func: FnMut(Prev::ItemOut) -> Out,
193194
= impl FnMut(&Context, Prev::ItemOut) -> Out;
194195

195196
pub type FilterNoCtxFn<Prev, Func>
196197
where
197198
Prev: BaseSurface,
199+
Func: FnMut(&Prev::ItemOut) -> bool,
198200
= impl FnMut(&Context, &Prev::ItemOut) -> bool;
199201

200202
pub type FilterMapNoCtxFn<Prev, Func, Out>
201203
where
202204
Prev: BaseSurface,
205+
Func: FnMut(Prev::ItemOut) -> Option<Out>,
203206
= impl FnMut(&Context, Prev::ItemOut) -> Option<Out>;
204207

205208
pub type InspectMapFunc<Prev, Func>
206209
where
207210
Prev: BaseSurface,
211+
Func: FnMut(&Context, &Prev::ItemOut),
208212
= impl FnMut(&Context, Prev::ItemOut) -> Prev::ItemOut;
209213

210214
pub type InspectMapNoCtxFunc<Prev, Func>
211215
where
212216
Prev: BaseSurface,
217+
Func: FnMut(&Prev::ItemOut),
213218
= impl FnMut(&Context, Prev::ItemOut) -> Prev::ItemOut;
214219

215220
pub trait PullSurface: BaseSurface {
@@ -443,12 +448,20 @@ pub trait PushSurface: BaseSurface {
443448

444449
pub type ForEachNoCtxFunc<Prev, Func>
445450
where
446-
Prev: BaseSurface,
451+
Prev: PushSurface,
452+
Func: FnMut(Prev::ItemOut),
447453
= impl FnMut(&Context, Prev::ItemOut);
448454

449455
pub type PartitionNoCtxOutput<Prev, Func, NextA, NextB>
450456
where
451-
Prev: BaseSurface,
457+
Prev: PushSurface,
458+
Func: Fn(&Prev::ItemOut) -> bool,
459+
NextA: PushSurfaceReversed<ItemIn = Prev::ItemOut>,
460+
NextB: PushSurfaceReversed<ItemIn = Prev::ItemOut>,
461+
462+
NextA::OutputHandoffs: Extend<NextB::OutputHandoffs>,
463+
<NextA::OutputHandoffs as Extend<NextB::OutputHandoffs>>::Extended:
464+
PortList<SEND> + PortListSplit<SEND, NextA::OutputHandoffs, Suffix = NextB::OutputHandoffs>,
452465
= push_partition::PartitionPushSurfaceReversed<
453466
NextA,
454467
NextB,

0 commit comments

Comments
 (0)