#[cfg(not(target_arch = "wasm32"))]
fn double(value: i32) -> i32 {
value * 2
}
#[cfg(not(target_arch = "wasm32"))]
fn main() {
let mut rx = main_loop_async::spawn_thread_with_return(|| double(5));
let task_result = loop {
match rx.try_recv() {
Ok(x) => {
if let Some(x) = x {
break x;
} else {
}
}
Err(err_msg) => panic!("sender was dropped, no value received: {err_msg}"),
}
};
assert_eq!(
task_result, 10,
"5 sent in and it should be doubled to be 10"
);
}
#[cfg(target_arch = "wasm32")]
fn main() {
}
#[cfg(all(test, not(target_arch = "wasm32")))]
mod tests {
#[test]
fn test_name() {
super::main();
}
}