-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlib.rs
53 lines (44 loc) · 1.52 KB
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#[macro_use]
extern crate cfg_if;
extern crate wasm_bindgen;
extern crate web_sys;
mod ball;
mod ball_collection;
mod render;
#[allow(non_snake_case)]
mod vector2D;
// use wasm_bindgen::prelude::*;
cfg_if! {
// When the `console_error_panic_hook` feature is enabled, we can call the
// `set_panic_hook` function to get better error messages if we ever panic.
if #[cfg(feature = "console_error_panic_hook")] {
extern crate console_error_panic_hook;
use console_error_panic_hook::set_once as set_panic_hook;
} else {
#[allow(dead_code)]
#[inline]
fn set_panic_hook() {}
}
}
cfg_if! {
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
if #[cfg(feature = "wee_alloc")] {
extern crate wee_alloc;
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
}
}
// Called by our JS entry point to run the example. - ⚠️ DISABLED (not called anymore)
// #[wasm_bindgen]
// pub fn run() -> Result<(), JsValue> {
// set_panic_hook();
// let window = web_sys::window().expect("should have a Window");
// let document = window.document().expect("should have a Document");
// let p: web_sys::Node = document.create_element("p")?.into();
// p.set_text_content(Some("Hello from Rust, WebAssembly, and Webpack!"));
// let body = document.body().expect("should have a body");
// let body: &web_sys::Node = body.as_ref();
// body.append_child(&p)?;
// Ok(())
// }