Same as [`std::vec::Vec::reserve`] but returns an error on allocation failure.
(&mut self, additional: usize)
| 118 | /// Same as [`std::vec::Vec::reserve`] but returns an error on allocation |
| 119 | /// failure. |
| 120 | pub fn reserve(&mut self, additional: usize) -> Result<(), OutOfMemory> { |
| 121 | self.inner.try_reserve(additional).map_err(|_| { |
| 122 | OutOfMemory::new( |
| 123 | self.len() |
| 124 | .saturating_add(additional) |
| 125 | .saturating_mul(mem::size_of::<T>()), |
| 126 | ) |
| 127 | }) |
| 128 | } |
| 129 | |
| 130 | /// Same as [`std::vec::Vec::reserve_exact`] but returns an error on allocation |
| 131 | /// failure. |
no test coverage detected