pub struct DefaultRecycle(_);
Expand description

A Recycle implementation for any type implementing Default and Clone.

This creates new elements by calling using Default::default(). Existing elements are recycled by calling Clone::clone_from with the default value.

Allocation Reuse

Clone::clone_from is not guaranteed to reuse existing allocations in place. For a number of common types in the standard library, such as Box, String, Vec, and collections based on Vec (such as VecDeque and BinaryHeap), clone_from is overridden to reuse existing allocations in place. However, other types may not override clone_from in this way.

DefaultRecycle will always work for types that implement Default and Clone, but it cannot be guaranteed to always reuse allocations. For a more restrictive Recycle implementation that will always reuse existing allocations, consider WithCapacity.

Implementations

Returns a new DefaultRecycle.

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

Returns the “default value” for a type. Read more

Returns a new instance of type T. Read more

Prepares element element for reuse. 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

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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.