Crates.io | dupit |
lib.rs | dupit |
version | 0.2.0 |
source | src |
created_at | 2024-10-06 08:49:44.99051 |
updated_at | 2024-10-06 14:07:22.194193 |
description | copy or clone a value |
homepage | https://github.com/drmingdrmer/dupit |
repository | https://github.com/drmingdrmer/dupit |
max_upload_size | |
id | 1398904 |
size | 8,647 |
Copy
or Clone
Derive dupit::Duplicate
for a type Foo
and use Foo::dup()
to copy or clone.
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();
}
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();
# }