Skip to content

A macro wrapping Rust closure calls that allows for capturing variables in scope on an individual bases.

License

Notifications You must be signed in to change notification settings

SLUCHABLUB/closure

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

closure - A Macro for Individually Capturing Variables

Latest version Documentation License

This is a fork of the closure crate by Oliver Giersch which is no longer maintained.

This crate provides a macro which lets you write closures that can capture variables individually, either by moving, referencing, or transforming by a method.

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] move |arg: i32| {
    ...
});

About

A macro wrapping Rust closure calls that allows for capturing variables in scope on an individual bases.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%