Crates.io | closure |
lib.rs | closure |
version | 0.3.0 |
source | src |
created_at | 2018-08-01 22:37:19.8967 |
updated_at | 2020-03-30 22:36:47.721087 |
description | A macro for capturing variables on a per variable basis. |
homepage | |
repository | https://github.com/oliver-giersch/closure.git |
max_upload_size | |
id | 77018 |
size | 16,546 |
This crate provides a macro which lets you write closures that can capture individually either by moving, referencing, mutably referencing of cloning.
Start by adding an entry to your Cargo.toml
:
[dependencies]
closure = "0.3.0"
Then you can write closures like so:
use closure::closure;
let string = "move".to_string();
let x = 10;
let mut y = 20;
let rc = Rc::new(5);
let closure = closure!(move string, ref x, ref mut y, clone rc, |arg: i32| {
...
});