2012-12-10 17:32:48 -08:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2015-01-01 23:53:35 -08:00
|
|
|
use std::thread::Thread;
|
2014-12-23 11:53:35 -08:00
|
|
|
use std::sync::mpsc::{Receiver, channel};
|
2012-05-29 17:48:27 -07:00
|
|
|
|
2014-03-09 14:58:32 -07:00
|
|
|
pub fn foo<T:Send + Clone>(x: T) -> Receiver<T> {
|
|
|
|
let (tx, rx) = channel();
|
2015-01-01 23:53:35 -08:00
|
|
|
Thread::spawn(move|| {
|
2014-03-09 14:58:32 -07:00
|
|
|
tx.send(x.clone());
|
2015-01-05 21:59:45 -08:00
|
|
|
});
|
2014-03-09 14:58:32 -07:00
|
|
|
rx
|
2012-05-29 17:48:27 -07:00
|
|
|
}
|