pub enum MaybeUninitAlloc<T>where
    T: ?Sized,
{ Init(OwnedAlloc<T>), Uninit(UninitAlloc<T>), }
Expand description

Pointer to memory allocaation that might be either initialized or uninitialized. For the drop checker, the type acts as if it contains a T due to usage of PhantomData<T>.

Variants

Init(OwnedAlloc<T>)

Initialized allocation.

Uninit(UninitAlloc<T>)

Uninitialized allocation.

Implementations

If the allocation was initialized, this is a no-op. If it wasn’t, the passed function is called and its return value is used to initialize the memory. In both cases, an allocation considered initialized is returned.

If the allocation was initialized, this is a no-op. If it wasn’t, the passed function is called with a mutable reference to the uninitialized memory and the function is expected to initialize the memory. In both cases, an allocation considered initialized is returned.

Safety

This function is unsafe because the passed function might not initialize the memory correctly.

Tests if the allocation is initialized.

Tests if the allocation is uninitialized.

If the memory is initialized, this function drops its content. In any case, the allocation now with uninitialized content is returned.

Encodes this type as a Result with an OwnedAlloc as Ok.

Encodes this type as a Result with an UninitAlloc as Ok.

If the memory is uninitialized, None is returned. If it is initialized, the passed function is called with a mutable reference to the allocation, and its return value is wrapped into a Some.

Trait Implementations

Formats the value using the given formatter. Read more
Converts to this type from the input type.
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 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.