MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / reserve

Method reserve

crates/core/src/alloc/vec.rs:120–128  ·  view source on GitHub ↗

Same as [`std::vec::Vec::reserve`] but returns an error on allocation failure.

(&mut self, additional: usize)

Source from the content-addressed store, hash-verified

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.

Callers 5

with_capacityMethod · 0.45
pushMethod · 0.45
resizeMethod · 0.45
resize_withMethod · 0.45
try_extendMethod · 0.45

Calls 3

try_reserveMethod · 0.80
newFunction · 0.50
lenMethod · 0.45

Tested by

no test coverage detected