I have that does the following type of recursion and works as expected:
fn test2(i: isize) -> (isize) {
println!("i={}", i);
return (i + 1);
}
fn main() {
let mut i = 1;
let mut j = 1;
for t in 0..4 {
(i) = test2(i);
}
}
i=1
i=2
i=3
i=4
The problem I have is what I really want is this recursion with multiple feedbacks like this.....
fn test(i: isize, j: isize) -> (isize, isize) {
println!("i={} j={}", i, j);
return (i + 1, j + 1);
}
fn main() {
for t in 0..4 {
let (i, j) = test(i, j);
println!("ii {} jj {}", i, j);
}
}
When I run the code I get the below:
i=1 j=1
ii 2 jj 2
i=1 j=1
ii 2 jj 2
i=1 j=1
ii 2 jj 2
i=1 j=1
ii 2 jj 2
If I leave off the let I get the below error:
for t in 0 .. 4 {
(i,j) = test(i, j);
println!("ii {} jj {}", i,j) ;
}
error[E0070]: invalid left-hand side expression
--> src/main.rs:265:13
|
265 | (i,j) = test(i, j);
| ^^^^^^^^^^^^^^^^^^ left-hand of expression not valid
How do I resolve?