#[repr(transparent)]
pub struct Emplacable<T, C>where
    T: ?Sized,
    C: EmplacableFn<T>,
{ /* private fields */ }
Expand description

A wrapped closure that you can pass to functions like box_new_with, that describes how to write a value of type T to a caller-provided allocation. You can get a T out of an Emplacable through functions like box_new_with. Alternately, you can drop the value of type T by dropping the Emplacable. Or you can forget the value of type T with Emplacable::forget.

Implementations

Create a new Emplacable from a closure. This is only useful if you are implementing a function that returns an unsized value as an Emplacable.

Safety

The closure closurse must, either diverge without returning, or, if it returns, then it must have used the emplacer to fully initalize the value.

Returns the closure inside this Emplacable.

This is only useful if you are implementing a function like box_new_with.

Emplaces this sized T onto the stack.

Runs the Emplacable closure, but doesn’t run the “inner closure”, so the value of type T is forgotten, and its destrutor is not run.

If you want to drop the T and run its destructor, drop the Emplacable instead.

Turns an emplacer for a sized type into one for an unsized type via an unsizing coercion (for example, array -> slice or concrete type -> trait object).

Creates an Emplacable for a slice of values of type T out of an iterator of values of type T.

This function differs from FromIterator::from_iter in that the iterator is required to be an ExactSizeIterator. If ExactSizeIterator is incorrectly implemented, this function may panic or otherwise misbehave (but will not trigger UB).

Turns this emplacer for a slice of Ts into an owned Vec<T>.

Turns this emplacer for a string slice into an owned, heap-allocated String.

Trait Implementations

Runs the contained closure to completion, instructing it to drop the value of type T.

Extends a collection with the contents of an iterator. Read more
🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. 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.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Creates a value from an iterator. Read more

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.