3 unstable releases

0.2.0 Oct 6, 2024
0.1.1 Oct 6, 2024
0.1.0 Oct 6, 2024

#164 in Procedural macros

Download history 300/week @ 2024-10-01 198/week @ 2024-10-08 17/week @ 2024-10-15 6/week @ 2024-10-29 18/week @ 2024-11-05

51 downloads per month

Apache-2.0

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

~245–700KB
~17K SLoC