pub use std::sync::mpsc::TryRecvError; use std::sync::mpsc::{self, Receiver}; pub struct Loader { rx: Receiver, } impl Loader { pub fn new T + Send + 'static>(f: F) -> Loader { let (tx, rx) = mpsc::sync_channel(0); std::thread::spawn(move || tx.send(f()).unwrap()); return Loader { rx }; } #[inline(always)] pub fn try_recv(&self) -> Result { self.rx.try_recv() } }