Crates.io | cloneable_dyn |
lib.rs | cloneable_dyn |
version | 0.1.1 |
source | src |
created_at | 2023-07-31 12:17:26.547797 |
updated_at | 2023-08-02 07:10:07.843588 |
description | Macros to make structs and enums clonable that use dyn Objects |
homepage | |
repository | https://github.com/StamesJames/cloneable_dyn |
max_upload_size | |
id | 930808 |
size | 18,109 |
I'm quite new to rust and even more so to publishing crates so this crate should be used with caution and feedback is welcome :-)
With this crate you can make your traits cloneablr, your structs/enums cloneable as given cloneable traits and derive clone on structs/enums that contain dyn objects of your traits.
Make a trait cloneable by attaching the attribute #[dyn_cloneable]. This will generate a new supertrait that contains a function fn clone_dyn(&self) -> Box<dyn #trait_ident>
Here an Example:
use cloneable_dyn::dyn_cloneable;
#[dyn_cloneable]
trait TestTrait {}
// will generate
// pub trait __TestTrait__DynCloneAutoDerive__ {
// fn clone_dyn(&self) -> Box<dyn TestTrait>;
// }
// and make it a supertrait of TestTrait