[−][src]Struct owned_alloc::OwnedAlloc
Dynamic allocation of a T
whose memory is considered fully initialized.
The allocation and its content are freed on drop
. Similar to a Box
. 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> OwnedAlloc<T>
[src]
impl<T> OwnedAlloc<T>
pub fn new(val: T) -> Self
[src]
pub fn new(val: T) -> Self
Creates an allocation and initializes it to the passed argument. In case of allocation error, the handler registered via stdlib is called.
pub fn try_new(val: T) -> Result<Self, AllocErr>
[src]
pub fn try_new(val: T) -> Result<Self, AllocErr>
Creates an allocation and initializes it to the passed argument. In case
of allocation error, Err
is returned.
pub fn move_inner(self) -> (T, UninitAlloc<T>)
[src]
pub fn move_inner(self) -> (T, UninitAlloc<T>)
Moves the stored value out from the allocation. The value and the allocation now considered uninitialized are returned.
impl<T> OwnedAlloc<T> where
T: ?Sized,
[src]
impl<T> OwnedAlloc<T> where
T: ?Sized,
pub unsafe fn from_raw(nnptr: NonNull<T>) -> Self
[src]
pub unsafe fn from_raw(nnptr: NonNull<T>) -> Self
Recreate the OwnedAlloc
from a raw non-null pointer.
Safety
This functions is unsafe
because passing the wrong pointer leads to
undefined behaviour. Passing a pointer to uninitialized memory is also
undefined behaviour.
pub unsafe fn from_box(boxed: Box<T>) -> Self
[src]
pub unsafe fn from_box(boxed: Box<T>) -> Self
Converts the plain old standard library Box
into an owned allocation.
Safety
This function is unsafe
because there are no guarantees that Box
and
OwnedAlloc
allocate in the same way. They probably do in the Rust
version you are using, but there are no future guarantees.
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 both the allocation and its content and returns its raw non-null pointer.
pub unsafe fn into_box(self) -> Box<T>
[src]
pub unsafe fn into_box(self) -> Box<T>
Converts the owned allocation into a plain old standard library Box
.
Safety
This function is unsafe
because there are no guarantees that Box
and
OwnedAlloc
allocate in the same way. They probably do in the Rust
version you are using, but there are no future guarantees.
pub fn drop_in_place(self) -> UninitAlloc<T>
[src]
pub fn drop_in_place(self) -> UninitAlloc<T>
Drops the memory and returns the allocation now considered uninitialized.
pub fn forget_inner(self) -> UninitAlloc<T>
[src]
pub fn forget_inner(self) -> UninitAlloc<T>
"Forgets" about dropping the inner value and returns an uninitialized allocation.
Trait Implementations
impl<T: ?Sized> Sync for OwnedAlloc<T> where
T: Sync,
[src]
impl<T: ?Sized> Sync for OwnedAlloc<T> where
T: Sync,
impl<T> From<T> for OwnedAlloc<T>
[src]
impl<T> From<T> for OwnedAlloc<T>
impl<T> From<OwnedAlloc<T>> for MaybeUninitAlloc<T> where
T: ?Sized,
[src]
impl<T> From<OwnedAlloc<T>> for MaybeUninitAlloc<T> where
T: ?Sized,
fn from(alloc: OwnedAlloc<T>) -> Self
[src]
fn from(alloc: OwnedAlloc<T>) -> Self
impl<T: ?Sized> Send for OwnedAlloc<T> where
T: Send,
[src]
impl<T: ?Sized> Send for OwnedAlloc<T> where
T: Send,
impl<T> Clone for OwnedAlloc<T> where
T: Clone,
[src]
impl<T> Clone for OwnedAlloc<T> where
T: Clone,
fn clone(&self) -> Self
[src]
fn clone(&self) -> Self
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<T> Drop for OwnedAlloc<T> where
T: ?Sized,
[src]
impl<T> Drop for OwnedAlloc<T> where
T: ?Sized,
impl<T> Debug for OwnedAlloc<T> where
T: ?Sized,
[src]
impl<T> Debug for OwnedAlloc<T> where
T: ?Sized,
impl<T> Deref for OwnedAlloc<T> where
T: ?Sized,
[src]
impl<T> Deref for OwnedAlloc<T> where
T: ?Sized,
impl<T> DerefMut for OwnedAlloc<T> where
T: ?Sized,
[src]
impl<T> DerefMut for OwnedAlloc<T> where
T: ?Sized,
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
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