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

Method into_raw_parts

crates/core/src/alloc/string.rs:199–216  ·  view source on GitHub ↗

Same as [`std::string::String::into_raw_parts`].

(mut self)

Source from the content-addressed store, hash-verified

197
198 /// Same as [`std::string::String::into_raw_parts`].
199 pub fn into_raw_parts(mut self) -> (*mut u8, usize, usize) {
200 // NB: Can't use `String::into_raw_parts` until our MSRV is >= 1.93.
201 #[cfg(not(miri))]
202 {
203 let ptr = self.as_mut_ptr();
204 let len = self.len();
205 let cap = self.capacity();
206 mem::forget(self);
207 (ptr, len, cap)
208 }
209 // NB: Miri requires using `into_raw_parts`, but always run on nightly,
210 // so it's fine to use there.
211 #[cfg(miri)]
212 {
213 let _ = &mut self;
214 self.inner.into_raw_parts()
215 }
216 }
217
218 /// Same as [`std::string::String::from_raw_parts`].
219 pub unsafe fn from_raw_parts(buf: *mut u8, length: usize, capacity: usize) -> Self {

Callers 2

shrink_to_fitMethod · 0.45
into_boxed_strMethod · 0.45

Calls 3

as_mut_ptrMethod · 0.45
lenMethod · 0.45
capacityMethod · 0.45

Tested by

no test coverage detected