| 404 | /// If `len` is greater than the buffer's current length, this has no effect |
| 405 | #[inline(always)] |
| 406 | pub fn truncate(&mut self, len: usize) { |
| 407 | if len > self.len { |
| 408 | return; |
| 409 | } |
| 410 | self.len = len; |
| 411 | #[cfg(feature = "pool")] |
| 412 | { |
| 413 | if let Some(reservation) = self.reservation.lock().unwrap().as_mut() { |
| 414 | reservation.resize(self.len); |
| 415 | } |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | /// Resizes the buffer, either truncating its contents (with no change in capacity), or |
| 420 | /// growing it (potentially reallocating it) and writing `value` in the newly available bytes. |