dupit

Crates.iodupit
lib.rsdupit
version0.2.0
sourcesrc
created_at2024-10-06 08:49:44.99051
updated_at2024-10-06 14:07:22.194193
descriptioncopy or clone a value
homepagehttps://github.com/drmingdrmer/dupit
repositoryhttps://github.com/drmingdrmer/dupit
max_upload_size
id1398904
size8,647
张炎泼 (drmingdrmer)

documentation

https://docs.rs/dupit

README

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();
# }
Commit count: 6

cargo fmt