captures

Crates.iocaptures
lib.rscaptures
version0.1.0
sourcesrc
created_at2021-11-26 22:16:38.80546
updated_at2021-11-26 22:16:38.80546
descriptionProvides macros to express more powerful closure captures
homepage
repositoryhttps://github.com/JakobDegen/captures
max_upload_size
id488172
size47,227
Jakob Degen (JakobDegen)

documentation

https://docs.rs/captures

README

More Powerful Closure Captures

This crate provides simple macros letting you express more powerful closure captures. For example, you can capture the clone of a value:

use std::rc::Rc;

let my_val = Rc::new(1);
captures::capture!(clone my_val, move || {
    // `my_val` is cloned here!
});

You can also capture arbitrary expressions and override the Edition-2021 capture semantics. Best of all, you can even specify that your closure should not capture any variables outside the ones you've listed:

let a = 1;
let b = 2;
captures::capture_only!(clone a, move || {
    a + b // errors: `b` is unknown
})

Consult the full documentation for the details.

Commit count: 2

cargo fmt