Minor clippy "iter_mut" bug, or is it me?

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 https://rust-lang.github.io/rust-clippy/master/index.html#needless_range_loop
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; 
    }

That looks like a bug to me. You should file an issue in the clippy repo about it.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.