Closed
Description
tl;dr Fix simple needless continue
for _ in 0..1 {
// do something
continue;
}
Currently, needless_continue
only checks possible removal of continue
by reordering if-else
block. One more simpler needless continue to be removed:
for _ in 0..(failed_count.get() - 1) {
match socket.write_all(portion) {
Ok(_) => return SendPortionResult::Success,
Err(err) => {
error!(
"Failed to send {} byte(s) >>> {}! Retrying the operation...",
helpers::cyan(portion.len()),
err
);
continue;
}
}
}
Which continue
can be dropped.
for _ in 0..(failed_count.get() - 1) {
match socket.write_all(portion) {
Ok(_) => return SendPortionResult::Success,
Err(err) => {
error!(
"Failed to send {} byte(s) >>> {}! Retrying the operation...",
helpers::cyan(portion.len()),
err
);
}
}
}
What needs to be achieve here is to check if there are any continue
at the end of each branches (including if-else
and match
blocks).
Possible code changes to clippy can probably be done in https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/needless_continue.rs#L374