// Platform helpers to ease future no_std portability. // The crate currently depends on `std`, but concentrating platform-specific // pieces here makes migration simpler. #[cfg(feature = "std")] pub use std::sync::Arc; #[cfg(feature = "std")] pub fn run_parallel(left: L, right: R) -> (OutL, OutR) where L: FnOnce() -> OutL + Send + 'static, R: FnOnce() -> OutR + Send + 'static, OutL: Send + 'static, OutR: Send + 'static, { let h1 = std::thread::spawn(left); let h2 = std::thread::spawn(right); (h1.join().unwrap(), h2.join().unwrap()) } #[cfg(not(feature = "std"))] mod no_std_support { extern crate alloc; pub use alloc::sync::Arc; pub fn run_parallel(left: L, right: R) -> (OutL, OutR) where L: FnOnce() -> OutL + Send + 'static, R: FnOnce() -> OutR + Send + 'static, OutL: Send + 'static, OutR: Send + 'static, { // No threads available: fall back to sequential execution. (left(), right()) } } #[cfg(not(feature = "std"))] pub use no_std_support::*;