Skip to content

Latest commit

 

History

History
39 lines (27 loc) · 986 Bytes

README.md

File metadata and controls

39 lines (27 loc) · 986 Bytes

Looking For Maintainers

This crate is no longer maintained. Feel free to contact the author if you'd like to continue developing it.

closure! - A macro for individually capturing variables

Latest version Documentation License

This crate provides a macro which lets you write closures that can capture individually either by moving, referencing, mutably referencing of cloning.

Usage

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| {
    ...
});