3 unstable releases
0.2.0 | Oct 6, 2024 |
---|---|
0.1.1 | Oct 6, 2024 |
0.1.0 | Oct 6, 2024 |
#233 in Procedural macros
24 downloads per month
6KB
73 lines
Duplicate a value via Copy
or Clone
Usage:
Derive dupit::Duplicate
for a type Foo
and use Foo::dup()
to copy or clone.
Example: duplicate a value via Clone
Value is duplicated via Clone
, if Copy
is not implemented.
# fn foo() {
use dupit::Duplicate;
#[derive(Clone, dupit::Duplicate)]
struct Cloneable;
let a = Cloneable.dup();
}
Example: duplicate a value via Copy
Value is duplicated via Copy
, if Copy
is implemented for it.
# fn foo() {
use dupit::Duplicate;
#[derive(Clone, Copy, dupit::Duplicate)]
struct Copyable;
let b = Copyable.dup();
# }
Dependencies
~230–670KB
~16K SLoC