Struct thingbuf::recycling::DefaultRecycle
source · [−]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
sourceimpl DefaultRecycle
impl DefaultRecycle
Trait Implementations
sourceimpl Clone for DefaultRecycle
impl Clone for DefaultRecycle
sourcefn clone(&self) -> DefaultRecycle
fn clone(&self) -> DefaultRecycle
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for DefaultRecycle
impl Debug for DefaultRecycle
sourceimpl Default for DefaultRecycle
impl Default for DefaultRecycle
sourcefn default() -> DefaultRecycle
fn default() -> DefaultRecycle
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl RefUnwindSafe for DefaultRecycle
impl Send for DefaultRecycle
impl Sync for DefaultRecycle
impl Unpin for DefaultRecycle
impl UnwindSafe for DefaultRecycle
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more