use std::thread; use std::sync::mpsc::{Receiver, channel}; pub fn foo(x: T) -> Receiver { let (tx, rx) = channel(); thread::spawn(move|| { tx.send(x.clone()); }); rx }