ps-buffer 0.1.0-21

aligned heap buffer
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::{Buffer, BufferError};

impl Buffer {
    /// # Errors
    /// - `AllocationError` is returned if allocation fails.
    /// - `DeallocationError` is returned if deallocation fails.
    pub fn resize(&mut self, new_len: usize, value: u8) -> Result<&mut Self, BufferError> {
        let len = self.len();

        if new_len <= len {
            Ok(self.truncate(new_len))
        } else {
            self.extend_with(new_len - len, value)
        }
    }
}