@@ -2,7 +2,10 @@ use std::fmt::Debug;
2
2
use crate :: core:: path:: slot:: slot:: Slot :: { Branch , FoldHood , Nbr , Rep } ;
3
3
use crate :: core:: vm:: round_vm:: round_vm:: RoundVM ;
4
4
5
- pub fn nbr < A : Copy + ' static > ( mut vm : RoundVM , expr : impl Fn ( RoundVM ) -> ( RoundVM , A ) ) -> ( RoundVM , A ) {
5
+ pub fn nbr < A : Copy + ' static , F > ( mut vm : RoundVM , expr : F ) -> ( RoundVM , A )
6
+ where
7
+ F : Fn ( RoundVM ) -> ( RoundVM , A )
8
+ {
6
9
vm. nest_in ( Nbr ( vm. index ( ) . clone ( ) ) ) ;
7
10
let ( mut vm_ , val) = match vm. neighbor ( ) {
8
11
Some ( nbr) if nbr. clone ( ) != vm. self_id ( ) => {
@@ -16,7 +19,11 @@ pub fn nbr<A: Copy + 'static>(mut vm: RoundVM, expr: impl Fn(RoundVM) -> (RoundV
16
19
( vm_, res)
17
20
}
18
21
19
- pub fn rep < A : Copy + ' static > ( mut vm : RoundVM , init : impl Fn ( ) -> A , fun : impl Fn ( RoundVM , A ) -> ( RoundVM , A ) ) -> ( RoundVM , A ) {
22
+ pub fn rep < A : Copy + ' static , F , G > ( mut vm : RoundVM , init : F , fun : G ) -> ( RoundVM , A )
23
+ where
24
+ F : Fn ( ) -> A ,
25
+ G : Fn ( RoundVM , A ) -> ( RoundVM , A ) ,
26
+ {
20
27
vm. nest_in ( Rep ( vm. index ( ) . clone ( ) ) ) ;
21
28
let ( mut vm_, val) = locally ( vm, |vm1| {
22
29
let prev = vm1. previous_round_val ( ) . unwrap_or ( & init ( ) ) . clone ( ) ;
@@ -27,7 +34,12 @@ pub fn rep<A: Copy + 'static>(mut vm: RoundVM, init: impl Fn() -> A, fun: impl F
27
34
( vm_, res)
28
35
}
29
36
30
- pub fn foldhood < A : Copy + ' static + Debug > ( mut vm : RoundVM , init : impl Fn ( ) -> A , aggr : impl Fn ( A , A ) -> A , expr : impl Fn ( RoundVM ) -> ( RoundVM , A ) ) -> ( RoundVM , A ) {
37
+ pub fn foldhood < A : Copy + ' static , F , G , H > ( mut vm : RoundVM , init : F , aggr : G , expr : H ) -> ( RoundVM , A )
38
+ where
39
+ F : Fn ( ) -> A ,
40
+ G : Fn ( A , A ) -> A ,
41
+ H : Fn ( RoundVM ) -> ( RoundVM , A ) ,
42
+ {
31
43
// here we do nest_in after retrieving the neighbours because otherwise it would disalign the device
32
44
33
45
vm. nest_in ( FoldHood ( vm. index ( ) . clone ( ) ) ) ;
0 commit comments