Crates.io | funky |
lib.rs | funky |
version | 0.0.1 |
source | src |
created_at | 2015-06-17 14:59:22.269839 |
updated_at | 2015-12-11 23:58:51.47213 |
description | Easily dispatch functions to a thread |
homepage | http://www.github.com/timonv/rust-funky |
repository | http://www.github.com/timonv/rust-funky |
max_upload_size | |
id | 2407 |
size | 2,412 |
Funky allows you to fire any function that implements Sync + Send quickly into a thread. The thread takes ownership of any arguments passed into the macro.
The macro returns a mpsc::Receiver on which you can block until you have the result.
Add to your Cargo.toml
funky = *
And run cargo install
Add to your main or lib file:
#[macro_use]
extern crate funky;
An example with no arguments:
let func = || -> String {
"abc".to_string()
};
let rx = funky!(func);
assert_eq!(rx.recv().unwrap(), "abc".to_string())
And with many arguments:
let func = |string: String| -> String {
string
};
let rx = funky!(func, "abc".to_string());
assert_eq!(rx.recv().unwrap(), "abc".to_string())