diff --git a/src/data_type/aligned_bytes.rs b/src/data_type/aligned_bytes.rs index dc43ad4..72abc18 100644 --- a/src/data_type/aligned_bytes.rs +++ b/src/data_type/aligned_bytes.rs @@ -29,6 +29,17 @@ where value: bytes, } } + + /// Use this for large allocations better suited to the heap. + /// + /// This fn also deals with [the boxed array issue in Rust](https://github.com/rust-lang/rust/issues/53827). + pub fn new_boxed() -> Box> { + let layout = std::alloc::Layout::new::>(); + unsafe { + let ptr = std::alloc::alloc(layout) as *mut AlignedBytes; + Box::from_raw(ptr) + } + } } impl Default for AlignedBytes