diff --git a/src/lib.rs b/src/lib.rs index 6b01431..6188eec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -381,6 +381,18 @@ impl HeapArray vec.into_boxed_slice() } } + + pub unsafe fn reinterpret(self) -> HeapArray + { + assert!(self.len_bytes() % std::mem::size_of::() == 0); + let output = HeapArray { + size: self.len_bytes() / std::mem::size_of::(), + ptr: self.ptr as *mut U, + drop_check: self.drop_check, + }; + std::mem::forget(self); + output + } } impl Index for HeapArray @@ -496,5 +508,20 @@ impl From> for HeapArray } } +impl From> for HeapArray +{ + fn from(sl: Box<[T]>) -> Self + { + Self::from_boxed_slice(sl) + } +} +impl From> for Box<[T]> +{ + fn from(ha: HeapArray) -> Self + { + ha.into_boxed_slice() + } +} + mod iter; pub use iter::*;