Converts a `Box ` into a `PointerBuf` without copying or allocating.
(self: Box<Pointer>)
| 587 | |
| 588 | /// Converts a `Box<Pointer>` into a `PointerBuf` without copying or allocating. |
| 589 | pub fn into_buf(self: Box<Pointer>) -> PointerBuf { |
| 590 | let inner = Box::into_raw(self); |
| 591 | // SAFETY: we ensure the layout of `Pointer` is the same as `str` |
| 592 | let inner = unsafe { Box::<str>::from_raw(inner as *mut str) }; |
| 593 | PointerBuf(inner.into_string()) |
| 594 | } |
| 595 | } |
| 596 | |
| 597 | #[cfg(feature = "serde")] |