diff --git a/hydroflow/src/builder/build/pull_filter.rs b/hydroflow/src/builder/build/pull_filter.rs index bc2336d3590d..25c46e4ca325 100644 --- a/hydroflow/src/builder/build/pull_filter.rs +++ b/hydroflow/src/builder/build/pull_filter.rs @@ -23,7 +23,7 @@ where type PullBuildImpl<'slf, 'ctx, Prev, Func> where Prev: PullBuild, - Func: 'slf, + Func: 'slf + FnMut(&Context, &Prev::ItemOut) -> bool, = std::iter::Filter, impl FnMut(&Prev::ItemOut) -> bool>; impl PullBuild for FilterPullBuild diff --git a/hydroflow/src/builder/build/pull_filter_map.rs b/hydroflow/src/builder/build/pull_filter_map.rs index 44d6d9778f87..d55b04f9f2b0 100644 --- a/hydroflow/src/builder/build/pull_filter_map.rs +++ b/hydroflow/src/builder/build/pull_filter_map.rs @@ -23,7 +23,7 @@ where type PullBuildImpl<'slf, 'ctx, Prev, Func, Out> where Prev: PullBuild, - Func: 'slf, + Func: 'slf + FnMut(&Context, Prev::ItemOut) -> Option, = std::iter::FilterMap, impl FnMut(Prev::ItemOut) -> Option>; impl PullBuild for FilterMapPullBuild diff --git a/hydroflow/src/builder/build/pull_fold_epoch.rs b/hydroflow/src/builder/build/pull_fold_epoch.rs index 0c0af0506237..74deea18e4fd 100644 --- a/hydroflow/src/builder/build/pull_fold_epoch.rs +++ b/hydroflow/src/builder/build/pull_fold_epoch.rs @@ -25,8 +25,8 @@ where type PullBuildImpl<'slf, 'ctx, Prev, Init, Func, Out> where Prev: 'slf + PullBuild, - Init: 'slf, - Func: 'slf, + Init: 'slf + FnMut(&Context) -> Out, + Func: 'slf + FnMut(&Context, Out, Prev::ItemOut) -> Out, = std::iter::OnceWith Out>; impl PullBuild for FoldEpochPullBuild diff --git a/hydroflow/src/builder/build/pull_map.rs b/hydroflow/src/builder/build/pull_map.rs index e14d768b37a6..f4cdf9ee90ee 100644 --- a/hydroflow/src/builder/build/pull_map.rs +++ b/hydroflow/src/builder/build/pull_map.rs @@ -23,7 +23,7 @@ where type PullBuildImpl<'slf, 'ctx, Prev, Func, Out> where Prev: PullBuild, - Func: 'slf, + Func: 'slf + FnMut(&Context, Prev::ItemOut) -> Out, = std::iter::Map, impl FnMut(Prev::ItemOut) -> Out>; impl PullBuild for MapPullBuild diff --git a/hydroflow/src/builder/build/push_filter.rs b/hydroflow/src/builder/build/push_filter.rs index 7309a79ce015..ac0631fd1f43 100644 --- a/hydroflow/src/builder/build/push_filter.rs +++ b/hydroflow/src/builder/build/push_filter.rs @@ -27,7 +27,7 @@ where type PushBuildImpl<'slf, 'ctx, Next, Func> where Next: PushBuild, - Func: 'slf, + Func: 'slf + FnMut(&Context, &Next::ItemIn) -> bool, = Filter bool, Next::Build<'slf, 'ctx>>; impl PushBuild for FilterPushBuild diff --git a/hydroflow/src/builder/build/push_filter_map.rs b/hydroflow/src/builder/build/push_filter_map.rs index 19ec5dbf1951..a1a408a4ca7b 100644 --- a/hydroflow/src/builder/build/push_filter_map.rs +++ b/hydroflow/src/builder/build/push_filter_map.rs @@ -34,7 +34,7 @@ where type PushBuildImpl<'slf, 'ctx, Next, Func, In> where Next: PushBuild, - Func: 'slf, + Func: 'slf + FnMut(&Context, In) -> Option, = FilterMap, impl FnMut(In) -> Option, In>; impl PushBuild for FilterMapPushBuild diff --git a/hydroflow/src/builder/build/push_for_each.rs b/hydroflow/src/builder/build/push_for_each.rs index aad5b420fbf1..bd1de1340705 100644 --- a/hydroflow/src/builder/build/push_for_each.rs +++ b/hydroflow/src/builder/build/push_for_each.rs @@ -30,7 +30,7 @@ where #[allow(type_alias_bounds)] type PushBuildImpl<'slf, 'ctx, Func, In> where - Func: 'slf, + Func: 'slf + FnMut(&Context, In), = ForEach; impl PushBuild for ForEachPushBuild diff --git a/hydroflow/src/builder/build/push_map.rs b/hydroflow/src/builder/build/push_map.rs index 3e12d97e5a7c..3c275bb4f283 100644 --- a/hydroflow/src/builder/build/push_map.rs +++ b/hydroflow/src/builder/build/push_map.rs @@ -34,7 +34,7 @@ where type PushBuildImpl<'slf, 'ctx, Next, Func, In> where Next: PushBuild, - Func: 'slf, + Func: 'slf + FnMut(&Context, In) -> Next::ItemIn, = Map Next::ItemIn, Next::Build<'slf, 'ctx>>; impl PushBuild for MapPushBuild diff --git a/hydroflow/src/builder/build/push_partition.rs b/hydroflow/src/builder/build/push_partition.rs index d29dc9f16cde..7fe9f38b1377 100644 --- a/hydroflow/src/builder/build/push_partition.rs +++ b/hydroflow/src/builder/build/push_partition.rs @@ -42,9 +42,13 @@ where #[allow(type_alias_bounds)] type PushBuildImpl<'slf, 'ctx, NextA, NextB, Func> where + Func: 'slf + FnMut(&Context, &NextA::ItemIn) -> bool, NextA: PushBuild, NextB: PushBuild, - Func: 'slf, + + NextA::OutputHandoffs: Extend, + >::Extended: + PortList + PortListSplit, = Partition< NextA::ItemIn, impl FnMut(&NextA::ItemIn) -> bool, diff --git a/hydroflow/src/builder/surface/map_scan.rs b/hydroflow/src/builder/surface/map_scan.rs index 5c9d83d69871..37974329e212 100644 --- a/hydroflow/src/builder/surface/map_scan.rs +++ b/hydroflow/src/builder/surface/map_scan.rs @@ -10,7 +10,11 @@ use crate::scheduled::context::Context; use crate::scheduled::flow_graph::NodeId; use crate::scheduled::state::StateHandle; -type MapScanFunc = impl FnMut(&Context, In) -> Out; +type MapScanFunc +where + Func: FnMut(&mut State, In) -> Out, + State: Any, += impl FnMut(&Context, In) -> Out; fn wrap_func( mut func: Func, diff --git a/hydroflow/src/builder/surface/mod.rs b/hydroflow/src/builder/surface/mod.rs index 6e3dce06f223..292d677c4bba 100644 --- a/hydroflow/src/builder/surface/mod.rs +++ b/hydroflow/src/builder/surface/mod.rs @@ -190,26 +190,31 @@ pub trait BaseSurface { pub type MapNoCtxFn where Prev: BaseSurface, + Func: FnMut(Prev::ItemOut) -> Out, = impl FnMut(&Context, Prev::ItemOut) -> Out; pub type FilterNoCtxFn where Prev: BaseSurface, + Func: FnMut(&Prev::ItemOut) -> bool, = impl FnMut(&Context, &Prev::ItemOut) -> bool; pub type FilterMapNoCtxFn where Prev: BaseSurface, + Func: FnMut(Prev::ItemOut) -> Option, = impl FnMut(&Context, Prev::ItemOut) -> Option; pub type InspectMapFunc where Prev: BaseSurface, + Func: FnMut(&Context, &Prev::ItemOut), = impl FnMut(&Context, Prev::ItemOut) -> Prev::ItemOut; pub type InspectMapNoCtxFunc where Prev: BaseSurface, + Func: FnMut(&Prev::ItemOut), = impl FnMut(&Context, Prev::ItemOut) -> Prev::ItemOut; pub trait PullSurface: BaseSurface { @@ -443,12 +448,20 @@ pub trait PushSurface: BaseSurface { pub type ForEachNoCtxFunc where - Prev: BaseSurface, + Prev: PushSurface, + Func: FnMut(Prev::ItemOut), = impl FnMut(&Context, Prev::ItemOut); pub type PartitionNoCtxOutput where - Prev: BaseSurface, + Prev: PushSurface, + Func: Fn(&Prev::ItemOut) -> bool, + NextA: PushSurfaceReversed, + NextB: PushSurfaceReversed, + + NextA::OutputHandoffs: Extend, + >::Extended: + PortList + PortListSplit, = push_partition::PartitionPushSurfaceReversed< NextA, NextB,