#closures #capture #clone #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

#2475 in Rust patterns

Download history 36/week @ 2024-07-22 57/week @ 2024-07-29 98/week @ 2024-08-05 48/week @ 2024-08-12 15/week @ 2024-08-19 72/week @ 2024-08-26 20/week @ 2024-09-02 16/week @ 2024-09-09 47/week @ 2024-09-16 86/week @ 2024-09-23 19/week @ 2024-09-30 10/week @ 2024-10-07 24/week @ 2024-10-14 13/week @ 2024-10-21 14/week @ 2024-10-28 20/week @ 2024-11-04

71 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