Crate try_clone

Crate try_clone 

Source
Expand description

Fallible cloning.

This crate defines TryClone, a small trait for types whose cloning operation can fail. Unlike Clone, which is infallible by design, TryClone returns a Result to allow implementations to report errors.

Implementations are provided for standard library types that expose a try_clone API, such as File, as well as for common containers and collections (Box, Arc, Vec, …) where appropriate APIs exists.

A blanket implementation is available behind the blanket-impl feature, which implements TryClone for all Clone types.

Traits§

TryClone
A fallible variant of Clone.
TryCloneToOwned
A trait for fallibly cloning a value into an owned form.

Functions§

try_clone
Creates a new instance of a value by fallibly cloning it.
try_clone_to_owned
Creates an owned version of a borrowed value fallibly.