parent
00a285bcdb
commit
0443248162
@ -1,32 +0,0 @@
|
|||||||
use super::*;
|
|
||||||
|
|
||||||
/// A wrapper type for a boxed slice of an unknown size
|
|
||||||
#[derive(Debug)]
|
|
||||||
#[repr(transparent)]
|
|
||||||
pub struct OwnedUnboundedSlice<T>
|
|
||||||
{
|
|
||||||
first: T
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> OwnedUnboundedSlice<T>
|
|
||||||
{
|
|
||||||
pub fn as_ptr(&self) -> *const T
|
|
||||||
{
|
|
||||||
&self.first as *const T
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn as_mut_ptr(&mut self) -> *mut T
|
|
||||||
{
|
|
||||||
&mut self.first as *mut T
|
|
||||||
}
|
|
||||||
|
|
||||||
pub unsafe fn as_slice(&self, size: usize) -> &[T]
|
|
||||||
{
|
|
||||||
std::slice::from_raw_parts(self.as_ptr(), size)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub unsafe fn as_mut_slice(&mut self, size: usize) -> &mut [T]
|
|
||||||
{
|
|
||||||
std::slice::from_raw_parts_mut(self.as_mut_ptr(), size)
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in new issue