Crates.io | clone-block |
lib.rs | clone-block |
version | 0.1.1 |
source | src |
created_at | 2020-08-30 15:16:52.10069 |
updated_at | 2020-08-30 15:22:37.553434 |
description | A very simple macro that clones a list of variables before calling an expression |
homepage | https://github.com/r3v2d0g/clone-block |
repository | https://git.r3vd5u3d.network/~r3v2d0g/clone-block |
max_upload_size | |
id | 282736 |
size | 23,725 |
Based on this tweet: https://twitter.com/untitaker/status/1299812136202493953
use clone_block::clone;
use std::thread;
let foo = "foo".to_string();
let thread = thread::spawn(
clone!(foo; move || {
let foobar = format!("{}bar", foo);
foobar
})
);
let foobar = thread.join();
let foobaz = format!("{}baz", foo);
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.