By using clippy I have to analyse some project and in that project i received clippy error (never_loop) due to following piece of code. I am confused why they used loop, whereas it always running one time (never loop).
fn me(&self) -> T {
for (i, n) in self.table.iter() {
return T::Meg {
cind: i,
cnr: (*nf).into(),
};
}
unsafe { unreachable_unchecked() }
}
so in above for loop entering into loop and immediately returning some value . Can anyone explain me why and when Never Loop is required ?
Thanks for your prompt reply. So you means that we don't need this type of for loop, at all. Actually I was thinking that above mentioned for loop could be replaced with if else statement. But, indeed, I want to know the reason behind why they used such kind of loop ( which never be a loop !).
Again thanks for your time. However, at this time, I don't need for any improvement in code. I just want to know the reason behind above mentioned for loop ! why they used such logic which seems to be never-loop. nothing else.