I will rewrite my previous, and unclear, question. My problem is when I try to return a value from a for loop.
That's works fine:
fn main() {
counter(5, 8);
}
fn counter(start: u32, end: u32) {
for n in start..=end {
println!("{}", n);
}
}
And that doesn't work:
fn main() {
let result = counter(5, 8);
println!("{}", result);
}
fn counter(start: u32, end: u32) -> u32 {
for n in start..=end {
n
}
}
And I try a lot of things and I can't make it work. I hope someone can help me to understand why.