33 lines
576 B
Rust
33 lines
576 B
Rust
|
mod utils;
|
||
|
|
||
|
use wasm_bindgen::prelude::*;
|
||
|
|
||
|
extern crate web_sys;
|
||
|
|
||
|
macro_rules! log {
|
||
|
( $( $t:tt )* ) => {
|
||
|
web_sys::console::log_1(&format!( $( $t )* ).into());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// 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 {
|
||
|
fn alert(s: &str);
|
||
|
}
|
||
|
|
||
|
#[wasm_bindgen]
|
||
|
pub fn greet() {
|
||
|
alert("Hello, Wazem!");
|
||
|
}
|
||
|
|
||
|
#[wasm_bindgen]
|
||
|
pub fn test_log() {
|
||
|
log!("Hello browser, Love Wazem!");
|
||
|
}
|