3 use wasm_bindgen
::prelude
::*;
6 // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
8 #[cfg(feature = "wee_alloc")]
10 static ALLOC
: wee_alloc
::WeeAlloc
= wee_alloc
::WeeAlloc
::INIT
;
18 pub fn greet(name
: &str) {
19 alert(&format!("Hello, {}!", name
));
20 console
::log_1(&"Hello bg".into());
23 #[wasm_bindgen(start)]
24 pub fn main() -> Result
<(), JsValue
> {
25 let window
= web_sys
::window().expect("no global `window` exists");
26 let document
= window
.document().expect("should have a document on window");
27 let body
= document
.body().expect("document should have a body");
29 let val
= document
.create_element("p")?
;
30 val
.set_inner_html("Hello from Rust!");
32 body
.append_child(&val
)?
;