From be5b14ef3affe9de5b0ad798146e31632c7e0b6f Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 8 Dec 2025 15:48:02 +0100 Subject: [PATCH] block: qcow: Implement Deref for VecCache Add Deref implementation for VecCache to allow direct slice operations without explicitly calling get_values(). This enables cleaner code patterns like cache.iter() instead of cache.get_values().iter(). Signed-off-by: Anatol Belski --- block/src/qcow/vec_cache.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/block/src/qcow/vec_cache.rs b/block/src/qcow/vec_cache.rs index d0c3acf08..0423bb6a5 100644 --- a/block/src/qcow/vec_cache.rs +++ b/block/src/qcow/vec_cache.rs @@ -7,7 +7,7 @@ use std::collections::HashMap; use std::collections::hash_map::IterMut; use std::io; -use std::ops::{Index, IndexMut}; +use std::ops::{Deref, Index, IndexMut}; use std::slice::SliceIndex; /// Trait that allows for checking if an implementor is dirty. Useful for types that are cached so @@ -85,6 +85,14 @@ impl IndexMut for VecCache { } } +impl Deref for VecCache { + type Target = [T]; + + fn deref(&self) -> &[T] { + &self.vec + } +} + #[derive(Clone, Debug)] pub struct CacheMap { capacity: usize,