Add wasm package

This commit is contained in:
Andras Schmelczer 2024-12-08 17:17:47 +00:00
parent 1e1934b492
commit e1ba3d44c7
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
5 changed files with 71 additions and 0 deletions

View file

@ -0,0 +1,19 @@
mod utils;
use wasm_bindgen::prelude::*;
// // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// // allocator.
// #[cfg(feature = "wee_alloc")]
// #[global_allocator]
// static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
// #[wasm_bindgen]
// extern "C" {
// fn alert(s: &str);
// }
#[wasm_bindgen]
pub fn greet() -> String {
"hi".to_string()
}

View file

@ -0,0 +1,10 @@
pub fn set_panic_hook() {
// When the `console_error_panic_hook` feature is enabled, we can call the
// `set_panic_hook` function at least once during initialization, and then
// we will get better error messages if our code ever panics.
//
// For more details see
// https://github.com/rustwasm/console_error_panic_hook#readme
#[cfg(feature = "console_error_panic_hook")]
console_error_panic_hook::set_once();
}