fn opt_clone_from_or_clone<'a, T: Clone>(
opt: &'a mut Option<T>,
val: &T,
) -> &'a mut T
Expand description
An analogue of Option::get_or_insert_with
that stores a clone of val
into opt
, but uses
the more efficient clone_from
if opt
was Some
.
Returns a mutable reference to the new clone that resides in opt
.