# try-clone
[](https://github.com/OpenByteDev/try-clone/actions/workflows/ci.yml) [](https://crates.io/crates/try-clone) [](https://docs.rs/try-clone) [](https://deps.rs/repo/github/openbytedev/try-clone) [](https://github.com/OpenByteDev/try-clone/blob/master/LICENSE)
Fallible cloning.
This crate defines [`TryClone`](https://docs.rs/try-clone/latest/try_clone/trait.TryClone.html), a small trait for types whose cloning operation can fail. Unlike [`Clone`](https://doc.rust-lang.org/std/clone/trait.Clone.html), which is infallible by design, [`TryClone`](https://docs.rs/try-clone/latest/try_clone/trait.TryClone.html) returns a [`Result`](https://doc.rust-lang.org/std/result/enum.Result.html) to allow implementations to report errors.
Implementations are provided for standard library types that expose a [`try_clone`](https://doc.rust-lang.org/stable/std/clone/index.html?search=try_clone) API, such as [`File`](https://doc.rust-lang.org/std/fs/struct.File.html), as well as for common containers and collections ([`Box`](https://doc.rust-lang.org/std/boxed/struct.Box.html), [`Arc`](https://doc.rust-lang.org/std/sync/struct.Arc.html), [`Vec`](https://doc.rust-lang.org/std/vec/struct.Vec.html), ...) where appropriate APIs exists.
A blanket implementation is available behind the `blanket-impl` feature, which implements [`TryClone`](https://docs.rs/try-clone/latest/try_clone/trait.TryClone.html) for all [`Clone`](https://doc.rust-lang.org/std/clone/trait.Clone.html) types.
## License
Licensed under the MIT license ([LICENSE](https://github.com/OpenByteDev/try-clone/blob/master/LICENSE) or http://opensource.org/licenses/MIT)