ps_buffer/methods/with_capacity.rs
1use crate::{Buffer, BufferError};
2
3impl Buffer {
4 /// # Errors
5 /// - `AllocationError` is returned if allocation fails.
6 /// - `DeallocationError` is returned if deallocation fails.
7 pub fn with_capacity(capacity: usize) -> Result<Self, BufferError> {
8 let mut buffer = Self::new();
9
10 buffer.reserve_total(capacity)?;
11
12 Ok(buffer)
13 }
14}