17 lines
322 B
Rust
17 lines
322 B
Rust
|
mod utils;
|
||
|
|
||
|
use wasm_bindgen::prelude::*;
|
||
|
|
||
|
// Import the `window.alert` function from the Web.
|
||
|
#[wasm_bindgen]
|
||
|
extern "C" {
|
||
|
fn alert(s: &str);
|
||
|
}
|
||
|
|
||
|
// Export a `greet` function from Rust to JavaScript, that alerts a
|
||
|
// hello message.
|
||
|
#[wasm_bindgen]
|
||
|
pub fn greet(name: &str) {
|
||
|
alert(&format!("Hello, {}!", name));
|
||
|
}
|