Last active
April 9, 2018 23:29
-
-
Save subtly/f10d7592f402089b96f5b4e2837b6150 to your computer and use it in GitHub Desktop.
rust learning puzzle #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::thread; | |
use std::sync::mpsc::channel; | |
fn main() { | |
let (tx, rx) = channel(); | |
// How to modify closure so only tx is captured? (without extra struct) | |
thread::spawn(move |tx| { | |
tx.send(String::from("hi")).unwrap(); | |
}); | |
println!("Got: {}", rx.recv().unwrap()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Capturing tx: