Struct owned_alloc::OwnedAlloc

source ·
pub struct OwnedAlloc<T>where
    T: ?Sized,
{ /* private fields */ }
Expand description

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>.

Implementations

Creates an allocation and initializes it to the passed argument. In case of allocation error, the handler registered via stdlib is called.

Creates an allocation and initializes it to the passed argument. In case of allocation error, Err is returned.

Moves the stored value out from the allocation. The value and the allocation now considered uninitialized are returned.

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.

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.

Returns the raw non-null pointer of the allocation.

“Forgets” dropping both the allocation and its content and returns its raw non-null pointer.

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.

Drops the memory and returns the allocation now considered uninitialized.

“Forgets” about dropping the inner value and returns an uninitialized allocation.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.
Executes the destructor for this type. Read more
Converts to this type from the input type.
Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Converts to this type from the input type.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.