Skip to content
This repository was archived by the owner on May 7, 2024. It is now read-only.

Commit d82b6a3

Browse files
lm98mergify[bot]
authored andcommitted
refactor: refactor lang functions signatures
1 parent bc28155 commit d82b6a3

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/core/lang/lang.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ use std::fmt::Debug;
22
use crate::core::path::slot::slot::Slot::{Branch, FoldHood, Nbr, Rep};
33
use crate::core::vm::round_vm::round_vm::RoundVM;
44

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+
{
69
vm.nest_in(Nbr(vm.index().clone()));
710
let (mut vm_ ,val) = match vm.neighbor() {
811
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
1619
(vm_, res)
1720
}
1821

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+
{
2027
vm.nest_in(Rep(vm.index().clone()));
2128
let (mut vm_, val) = locally(vm, |vm1| {
2229
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
2734
(vm_, res)
2835
}
2936

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+
{
3143
// here we do nest_in after retrieving the neighbours because otherwise it would disalign the device
3244

3345
vm.nest_in(FoldHood(vm.index().clone()));

0 commit comments

Comments
 (0)