today's studying
This commit is contained in:
parent
171c8d5489
commit
71db955e55
10 changed files with 446 additions and 2 deletions
19
20-dev/00-rust/30-fearless/mpsc.md
Normal file
19
20-dev/00-rust/30-fearless/mpsc.md
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
Круто!
|
||||
|
||||
```rust
|
||||
use std::sync::mpsc;
|
||||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
let (tx, rx) = mpsc::channel();
|
||||
|
||||
thread::spawn(move || {
|
||||
let val = String::from("hi");
|
||||
tx.send(val).unwrap();
|
||||
});
|
||||
|
||||
let received = rx.recv().unwrap();
|
||||
println!("Got: {received}");
|
||||
}
|
||||
```
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue