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

Method resize_with

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

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

(&mut self, new_len: usize, f: F)

Source from the content-addressed store, hash-verified

194 /// Same as [`std::vec::Vec::resize_with`] but returns an error on
195 /// allocation failure.
196 pub fn resize_with<F>(&mut self, new_len: usize, f: F) -> Result<(), OutOfMemory>
197 where
198 F: FnMut() -> T,
199 {
200 let len = self.len();
201 if new_len > len {
202 self.reserve(new_len - len)?;
203 }
204 self.inner.resize_with(new_len, f);
205 Ok(())
206 }
207
208 /// Same as [`std::vec::Vec::retain`].
209 pub fn retain<F>(&mut self, f: F)

Callers 9

newMethod · 0.80
set_inputMethod · 0.80
call_impl_do_callMethod · 0.80
newMethod · 0.80
new_dynamicMethod · 0.80
growMethod · 0.80
poll_oneoff_implFunction · 0.80
poll_oneoff_implFunction · 0.80
poll_oneoff_with_retryFunction · 0.80

Calls 3

OkFunction · 0.85
lenMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected