blob: da1469bf557687e096f419bcf907522002a063b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
use wasm_bindgen::prelude::*;
mod forth;
#[wasm_bindgen]
extern {
#[wasm_bindgen(js_namespace = console)]
fn debug(s: &str);
}
#[wasm_bindgen(start)]
pub fn run() -> Result<(), JsValue> {
let window = web_sys::window().expect("no global `window` exists");
let document = window.document().expect("should have `document` on window");
let body = document.body().expect("document should have `body`");
let val = document.create_element("p")?;
val.set_text_content(Some("hi there"));
body.append_child(&val)?;
debug("done in rust's run");
Ok(())
}
|