mirror of https://github.com/rust-lang/rust
23 lines
437 B
Rust
23 lines
437 B
Rust
//@ run-pass
|
|
#![allow(unused_must_use)]
|
|
//@ needs-threads
|
|
|
|
use std::thread;
|
|
use std::sync::mpsc::{channel, Sender};
|
|
|
|
fn producer(tx: &Sender<Vec<u8>>) {
|
|
tx.send(
|
|
vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
|
|
13]).unwrap();
|
|
}
|
|
|
|
pub fn main() {
|
|
let (tx, rx) = channel::<Vec<u8>>();
|
|
let prod = thread::spawn(move|| {
|
|
producer(&tx)
|
|
});
|
|
|
|
let _data: Vec<u8> = rx.recv().unwrap();
|
|
prod.join();
|
|
}
|