clone_dyn_meta/
lib.rs

1#![doc(html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png")]
2#![doc(
3  html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico"
4)]
5#![doc(html_root_url = "https://docs.rs/clone_dyn_meta/latest/clone_dyn_meta/")]
6#![ cfg_attr( doc, doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "readme.md" ) ) ) ]
7#![ cfg_attr( not( doc ), doc = "Dynamic cloning macro support" ) ]
8
9/// Internal namespace.
10mod internal {}
11
12/// Derive macro for `CloneDyn` trait.
13///
14/// It is a procedural macro that generates an implementation of the `CloneDyn` trait for a given type.
15///
16/// ### Sample.
17///
18/// ```rust
19/// #[ cfg( feature = "derive_clone_dyn" ) ]
20/// #[ clone_dyn ]
21/// pub trait Trait1
22/// {
23///   fn f1( &self );
24/// }
25///
26/// #[ cfg( feature = "derive_clone_dyn" ) ]
27/// #[ clone_dyn ]
28/// pub trait Trait2: Trait1
29/// {
30///   fn f2( &self );
31/// }
32/// ```
33///
34/// To learn more about the feature, study the module [`clone_dyn`](https://docs.rs/clone_dyn/latest/clone_dyn/).
35#[ proc_macro_attribute ]
36pub fn clone_dyn(attr: proc_macro::TokenStream, item: proc_macro::TokenStream) -> proc_macro::TokenStream 
37{
38  let result = clone_dyn::clone_dyn(attr, item);
39  match result 
40  {
41  Ok(stream) => stream.into(),
42  Err(err) => err.to_compile_error().into(),
43 }
44}
45
46/// Implementation of `clone_dyn` macro.
47mod clone_dyn;