-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.rs
27 lines (21 loc) · 818 Bytes
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//! Unified entrypoint for native and web `xwt` example client.
//!
//! The reason to have the unified entrypoint is to have a `bin` target that has
//! a `main` fn on each of the platforms that we test against, so that
//! the compiler doesn't complain about missing `main` in the native bin when
//! we are testing wasm and vice versa.
cfg_if::cfg_if! {
if #[cfg(target_family = "wasm")] {
fn main() {
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
wasm_bindgen_futures::spawn_local(async move {
xwt_example_client_web::main().await.unwrap()
})
}
} else {
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
xwt_example_client_native::main().await
}
}
}