3 unstable releases

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

#170 in Procedural macros

Download history 230/week @ 2024-09-30 258/week @ 2024-10-07 27/week @ 2024-10-14

515 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

~260–710KB
~17K SLoC