{"id":16476277,"url":"https://github.com/dominicburkart/funfun","last_synced_at":"2026-06-21T02:32:13.872Z","repository":{"id":57632296,"uuid":"144408601","full_name":"DominicBurkart/funfun","owner":"DominicBurkart","description":"Macros for working with closures in Rust.","archived":false,"fork":false,"pushed_at":"2018-08-29T21:29:21.000Z","size":31,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-11T08:48:15.988Z","etag":null,"topics":["functional-programming","memory-allocation","parallel","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DominicBurkart.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-11T18:19:30.000Z","updated_at":"2023-03-01T07:05:23.000Z","dependencies_parsed_at":"2022-08-31T12:03:45.325Z","dependency_job_id":null,"html_url":"https://github.com/DominicBurkart/funfun","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DominicBurkart%2Ffunfun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DominicBurkart%2Ffunfun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DominicBurkart%2Ffunfun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DominicBurkart%2Ffunfun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DominicBurkart","download_url":"https://codeload.github.com/DominicBurkart/funfun/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241180790,"owners_count":19923293,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["functional-programming","memory-allocation","parallel","rust"],"created_at":"2024-10-11T12:41:57.428Z","updated_at":"2025-11-10T14:34:28.331Z","avatar_url":"https://github.com/DominicBurkart.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# funfun\n\n[![Build Status](https://travis-ci.org/DominicBurkart/funfun.svg?branch=master)](https://travis-ci.org/DominicBurkart/funfun)\n[![Coverage Status](https://coveralls.io/repos/github/DominicBurkart/funfun/badge.svg?branch=master)](https://coveralls.io/github/DominicBurkart/funfun?branch=master)\n[![Codecov Coverage Status](https://codecov.io/gh/DominicBurkart/funfun/branch/master/graphs/badge.svg)](https://codecov.io/gh/DominicBurkart/funfun)\n[![Crates.io](https://img.shields.io/crates/v/funfun.svg)](https://crates.io/crates/funfun)\n[![Rust Documentation](https://docs.rs/funfun/badge.svg)](https://docs.rs/funfun)\n\n\n### spawn_fn!\n```spawn_fn!``` Takes a closure or function and its arguments, runs the\nclosure or function with the passed arguments in a new thread, and\nreturns the thread's hook.\n\n``` rust\nlet eg = box_fn!(|x: i32| -\u003e i32 {x + 2});\nlet also = box_fn!(|x: i32, y: i32| -\u003e i32 {x + y});\n\nlet mut v1 = Vec::new();\nfor i1 in 0..10000 {\n    let i2 = i1 + 10;\n    v1.push(spawn_fn!(eg, i1));\n    v1.push(spawn_fn!(also, i1, i2)); // woohoo multi-arity!\n}\nv1.push(spawn_fn!(||{println!(\"accepts closures to run in their own thread!\"); 1}));\n\nfor res in v1.into_iter() {\n    res.join();\n}\n```\n\n### box_fn!\n```box_fn!``` Boxes a closure and returns an Rc pointer.\n``` rust\ntype T = BoxFn\u003cFn(\u0026str) -\u003e String\u003e;\nstruct F {\n    c: T\n}\nlet c: T = box_fn!(|s: \u0026str| -\u003e String {s.to_string()});\nlet mut f = F { c };\nf.c = box_fn!(\n    |d: \u0026str| -\u003e String {\"reassign once\".to_string()}\n);\nf.c = box_fn!(\n    |_: \u0026str| {\"and again\".to_string()}\n);\n```\n\n### arc_fn!\n```arc_fn!``` Boxes a closure and returns an Arc pointer. Slower than\nan Rc pointer, but allows derivation of traits like Clone.\n``` rust\ntype T = ArcFn\u003cFn(\u0026str) -\u003e String\u003e;\n#[derive(Clone)]\nstruct F {\n    c: T\n}\nlet c: T = arc_fn!(|s: \u0026str| -\u003e String {s.to_string()});\nlet mut f = F { c };\nf.c = arc_fn!(\n    |d: \u0026str| -\u003e String {\"reassign once\".to_string()}\n);\nf.c = arc_fn!(\n    |_: \u0026str| {\"and again\".to_string()}\n);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdominicburkart%2Ffunfun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdominicburkart%2Ffunfun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdominicburkart%2Ffunfun/lists"}