How to do for loop with multiple limits

for (int i = 0; i <= 6 && i + Configuration.ADSEED < sequence.length(); i++) {
    // blah
}

It seems that the above jave code iters over i with multiple conditions. (i<=6 and i + Configuration.ADSEED < sequence.length())

How can I do the for loop in rust?

Thanks in advance.

for i in (0..=6).take_while(|&i| i + Configuration::ADSEED < sequence.len())

You can put as much logic in take_while as you like.

2 Likes