Same as [`std::string::String::into_raw_parts`].
(mut self)
| 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 { |
no test coverage detected