Extends the cache capacity to `new_len` elements. No-op if `new_len <= self.len()`. Allocates a new buffer, copies existing data, and fills new elements with default values. Marks the cache as dirty.
(&mut self, new_len: usize)
| 69 | /// existing data, and fills new elements with default values. |
| 70 | /// Marks the cache as dirty. |
| 71 | pub fn extend(&mut self, new_len: usize) { |
| 72 | if new_len <= self.vec.len() { |
| 73 | return; |
| 74 | } |
| 75 | let mut new_vec = vec![Default::default(); new_len]; |
| 76 | new_vec[..self.vec.len()].copy_from_slice(&self.vec); |
| 77 | self.vec = new_vec.into_boxed_slice(); |
| 78 | self.dirty = true; |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | impl<T: 'static + Copy + Default> Cacheable for VecCache<T> { |
no test coverage detected