Skip to content

Latest commit

 

History

History
 
 

clone_dyn

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Module :: clone_dyn

experimental rust-status docs.rs Open in Gitpod discord

Derive to clone dyn structures.

The crate's purpose is straightforward: it allows for easy cloning of dyn< Trait > with minimal effort and complexity, accomplished by applying the derive attribute to the trait.

Alternative

There are few alternatives dyn-clone, dyn-clonable. Unlike other options, this solution is more concise and demands less effort to use, all without compromising the quality of the outcome. Also, you can ask an inquiry and get answers, which is problematic in the case of alternatives.

Basic use-case

#[ cfg( feature = "enabled" ) ]
{
  use clone_dyn::clone_dyn;

  #[ clone_dyn ]
  trait Trait1
  {
  }

  let vec = Vec::< Box< dyn Trait1 > >::new();
  let vec2 = vec.clone(); /* <- it does not work without `clone_dyn` */
}

To add to your project

cargo add clone_dyn

Try out from the repository

git clone https://github.com/Wandalen/wTools
cd wTools
cd examples/clone_dyn_trivial
cargo run