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

Method finish

crates/core/src/alloc/boxed.rs:159–167  ·  view source on GitHub ↗

Finish this builder and take its boxed slice out. Panics if `self.init_len() != self.capacity()`. Call `self.shrink_to_fit()` if necessary.

(mut self)

Source from the content-addressed store, hash-verified

157 /// Panics if `self.init_len() != self.capacity()`. Call
158 /// `self.shrink_to_fit()` if necessary.
159 pub fn finish(mut self) -> Box<[T]> {
160 assert_eq!(self.init_len(), self.capacity());
161 let vec = mem::take(&mut self.vec);
162 mem::forget(self);
163 let (ptr, len, cap) = vec.into_raw_parts();
164 debug_assert_eq!(len, cap);
165 let ptr = core::ptr::slice_from_raw_parts_mut(ptr, len);
166 unsafe { Box::from_raw(ptr) }
167 }
168
169 /// Shrink this builder's allocation such that `self.init_len() ==
170 /// self.capacity()`.

Callers 15

fmtMethod · 0.45
fmtMethod · 0.45
fmtMethod · 0.45
fmtMethod · 0.45
fmtMethod · 0.45
fmtMethod · 0.45
fmtMethod · 0.45
fmtMethod · 0.45
fmtMethod · 0.45
fmtMethod · 0.45
fmtMethod · 0.45
fmtMethod · 0.45

Calls 2

slice_from_raw_parts_mutFunction · 0.85
into_raw_partsMethod · 0.45

Tested by 15

fmtMethod · 0.36
fmtMethod · 0.36
fmtMethod · 0.36
fmtMethod · 0.36
fmtMethod · 0.36
fmtMethod · 0.36
fmtMethod · 0.36
fmtMethod · 0.36
fmtMethod · 0.36
fmtMethod · 0.36
fmtMethod · 0.36
fmtMethod · 0.36