I have multiple while loops inside a for loop, and I want to use the index of the current loop as the starting value of both while loops like this:
for n in 0..10 {
let mut j = n;
while j > 0 {
j/=2;
}
j = n;
while j > 0 {
j/=2;
}
}
I've heard of shadowing but I can't think of a way to have it limited to the inside of the while loop and also be the condition for the while loop. I feel like there should be a better way to do this but I can't find it anywhere. is this really the correct way to do this or is there a nicer way I'm not seeing?
What exactly is to be achieved is not quite clear. If you want to run through the
forloop with a new starting value, use a'labelfor theforloop.Playground