[−][src]Struct owned_alloc::UninitAlloc
Dynamic allocation of a T
whose memory is considered uninitialized. The
allocation is freed on drop
. If the size of the allocation is zero, no
allocation is performed and a dangling pointer is used (just like in std
).
For the drop checker, the type acts as if it contains a T
due to usage of
PhantomData<T>
.
Methods
impl<T> UninitAlloc<T>
[src]
impl<T> UninitAlloc<T>
pub fn new() -> Self
[src]
pub fn new() -> Self
Creates room for a T
. In case of allocation error, the handler
registered via stdlib is called.
pub fn try_new() -> Result<Self, AllocErr>
[src]
pub fn try_new() -> Result<Self, AllocErr>
Creates room for a T
. In case of allocation error, Err
is returned.
pub fn init(self, val: T) -> OwnedAlloc<T>
[src]
pub fn init(self, val: T) -> OwnedAlloc<T>
Initializes the memory and returns the allocation now considered initialized.
impl<T> UninitAlloc<T> where
T: ?Sized,
[src]
impl<T> UninitAlloc<T> where
T: ?Sized,
pub unsafe fn init_in_place<F>(self, init: F) -> OwnedAlloc<T> where
F: FnOnce(&mut T),
[src]
pub unsafe fn init_in_place<F>(self, init: F) -> OwnedAlloc<T> where
F: FnOnce(&mut T),
Calls a function with a mutable reference to uninitialized memory and returns the allocation now considered initialized. The passed function is expected to initialize the memory.
Safety
This function is unsafe
because the passed function might not
initialize the memory correctly.
pub unsafe fn from_raw(nnptr: NonNull<T>) -> Self
[src]
pub unsafe fn from_raw(nnptr: NonNull<T>) -> Self
Recreate the UninitAlloc
from a raw non-null pointer.
Safety
This functions is unsafe
because passing the wrong pointer leads to
undefined behaviour.
pub fn raw(&self) -> NonNull<T>
[src]
pub fn raw(&self) -> NonNull<T>
Returns the raw non-null pointer of the allocation.
pub fn into_raw(self) -> NonNull<T>
[src]
pub fn into_raw(self) -> NonNull<T>
"Forgets" dropping the allocation and returns its raw non-null pointer.
Trait Implementations
impl<T: ?Sized> Sync for UninitAlloc<T> where
T: Sync,
[src]
impl<T: ?Sized> Sync for UninitAlloc<T> where
T: Sync,
impl<T> From<RawVec<T>> for UninitAlloc<[T]>
[src]
impl<T> From<RawVec<T>> for UninitAlloc<[T]>
impl<T> From<UninitAlloc<T>> for RawVec<T>
[src]
impl<T> From<UninitAlloc<T>> for RawVec<T>
fn from(alloc: UninitAlloc<T>) -> Self
[src]
fn from(alloc: UninitAlloc<T>) -> Self
impl<T> From<UninitAlloc<T>> for MaybeUninitAlloc<T> where
T: ?Sized,
[src]
impl<T> From<UninitAlloc<T>> for MaybeUninitAlloc<T> where
T: ?Sized,
fn from(alloc: UninitAlloc<T>) -> Self
[src]
fn from(alloc: UninitAlloc<T>) -> Self
impl<T: ?Sized> Send for UninitAlloc<T> where
T: Send,
[src]
impl<T: ?Sized> Send for UninitAlloc<T> where
T: Send,
impl<T> Drop for UninitAlloc<T> where
T: ?Sized,
[src]
impl<T> Drop for UninitAlloc<T> where
T: ?Sized,
impl<T> Debug for UninitAlloc<T> where
T: ?Sized,
[src]
impl<T> Debug for UninitAlloc<T> where
T: ?Sized,
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T