#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

#2018 in Rust patterns

Download history 22/week @ 2023-12-11 4/week @ 2023-12-18 3/week @ 2023-12-25 6/week @ 2024-01-01 73/week @ 2024-01-08 44/week @ 2024-01-15 20/week @ 2024-01-22 23/week @ 2024-01-29 15/week @ 2024-02-05 51/week @ 2024-02-12 40/week @ 2024-02-19 79/week @ 2024-02-26 65/week @ 2024-03-04 38/week @ 2024-03-11 26/week @ 2024-03-18 39/week @ 2024-03-25

172 downloads per month
Used in 5 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