Struct thingbuf::recycling::DefaultRecycle
source · pub struct DefaultRecycle(/* private fields */);
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§
Trait Implementations§
source§impl Clone for DefaultRecycle
impl Clone for DefaultRecycle
source§fn clone(&self) -> DefaultRecycle
fn clone(&self) -> DefaultRecycle
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more