Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

timonv/rust-funky

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Funky!

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.

Don't use this in production code! These are native threads. This is just an exploration in macro usage.

Installation

Add to your Cargo.toml

funky = "*"

And run cargo install

Usage

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())

About

Easily dispatch functions to a thread

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages