MCPcopy Create free account
hub / github.com/chanced/jsonptr / into_buf

Method into_buf

src/pointer.rs:589–594  ·  view source on GitHub ↗

Converts a `Box ` into a `PointerBuf` without copying or allocating.

(self: Box<Pointer>)

Source from the content-addressed store, hash-verified

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")]

Callers 1

from_box_to_bufFunction · 0.80

Calls 1

PointerBufClass · 0.85

Tested by 1

from_box_to_bufFunction · 0.64