block: Fix clippy: chunks_exact with constant chunk size

```
warning: using `chunks_exact` with a constant chunk size
   --> block/src/formats/qcow/internal/header.rs:253:39
    |
253 |                     for entry in data.chunks_exact(FEATURE_NAME_ENTRY_SIZE) {
    |                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `as_chunks` instead
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#chunks_exact_to_as_chunks
    = note: `-D clippy::chunks-exact-to-as-chunks` implied by `-D clippy::all`
```

Signed-off-by: Rob Bradford <rbradford@meta.com>
This commit is contained in:
Rob Bradford
2026-07-06 23:27:55 +01:00
parent 2a3512fb71
commit f5468a6dae
2 changed files with 5 additions and 3 deletions

View File

@@ -250,7 +250,7 @@ impl QcowHeader {
.map_err(Error::ReadingHeader)?;
offset += data.len() as u64;
let table = feature_table.as_mut().unwrap();
for entry in data.chunks_exact(FEATURE_NAME_ENTRY_SIZE) {
for entry in data.as_chunks::<FEATURE_NAME_ENTRY_SIZE>().0 {
if entry[0] == FEAT_TYPE_INCOMPATIBLE {
let bit_number = entry[1];
let name_bytes = &entry[2..];

View File

@@ -203,8 +203,10 @@ impl QcowRawFile {
self.file.read_exact_at(&mut bytes, offset)?;
let m = mask.unwrap_or(u64::MAX);
let table = bytes
.chunks_exact(size_of::<u64>())
.map(|c| u64::from_be_bytes(c.try_into().unwrap()) & m)
.as_chunks::<{ size_of::<u64>() }>()
.0
.iter()
.map(|c| u64::from_be_bytes(*c) & m)
.collect();
Ok(table)
}