I had the following code:
for i in 0..n_len_code
{
result.bd.nbits[ CLEN_ALPHABET[i] as usize ] = inp.get_bits(3) as u8;
}
Clippy complained:
--> src\inflate.rs:277:14
|
277 | for i in 0..n_len_code
| ^^^^^^^^^^^^^
|
= note: #[warn(clippy::needless_range_loop)]
on by default
= help: for further information visit Clippy Lints
help: consider using an iterator
|
277 | for in CLEN_ALPHABET.iter_mut().take(n_len_code)
| ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: 1 warning emitted
However it seems the "iter_mut" suggestion is inaccurate, what I needed was I think this, just "iter" without the "_mut":
for i in CLEN_ALPHABET.iter().take(n_len_code)
{
result.bd.nbits[ *i as usize ] = inp.get_bits(3) as u8;
}