Ensure that `count` bytes from `start` contain zero bits This is used to initialize the bits in a buffer, however, it has no impact on the `len` of the buffer and so can be used to initialize the memory region from `len` to `capacity`. # Panics Panics if the byte range `start..start + count` exceeds the buffer capacity.
(&mut self, start: usize, count: usize)
| 246 | /// |
| 247 | /// Panics if the byte range `start..start + count` exceeds the buffer capacity. |
| 248 | pub fn set_null_bits(&mut self, start: usize, count: usize) { |
| 249 | assert!( |
| 250 | start.saturating_add(count) <= self.layout.size(), |
| 251 | "range start index {start} and count {count} out of bounds for \ |
| 252 | buffer of length {}", |
| 253 | self.layout.size(), |
| 254 | ); |
| 255 | |
| 256 | // Safety: `self.data[start..][..count]` is in-bounds and well-aligned for `u8` |
| 257 | unsafe { |
| 258 | std::ptr::write_bytes(self.data.as_ptr().add(start), 0, count); |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | /// Ensures that this buffer has at least `self.len + additional` bytes. This re-allocates iff |
| 263 | /// `self.len + additional > capacity`. |