#closures #clone #capture #lambda #dom

clonelet

A simple macro to capture by clone in closures

2 unstable releases

0.2.0 Jul 30, 2023
0.1.0 Jul 30, 2023

#2452 in Rust patterns

Download history 43/week @ 2024-09-01 16/week @ 2024-09-08 48/week @ 2024-09-15 75/week @ 2024-09-22 30/week @ 2024-09-29 10/week @ 2024-10-06 23/week @ 2024-10-13 12/week @ 2024-10-20 15/week @ 2024-10-27 20/week @ 2024-11-03 1/week @ 2024-11-10 11/week @ 2024-11-17 25/week @ 2024-11-24 26/week @ 2024-12-01 84/week @ 2024-12-08 27/week @ 2024-12-15

164 downloads per month
Used in 7 crates (3 directly)

MIT/Apache

5KB
91 lines

Clonelet

A simple macro to capture by clone in closures. Your closure doesn't need to live inside a macro.

Example

let closure = {
    clone!(x, y, mut z);

    move || {}
};

Generates:

let closure = {
    let x = x.clone();
    let y = y.clone();
    let mut z = z.clone();

    move || {}
};

No runtime deps