This repository was archived by the owner on Aug 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-20
lines changed Expand file tree Collapse file tree 2 files changed +12
-20
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ edition = "2018"
1313crate-type = [" cdylib" ]
1414
1515[dependencies ]
16- cfg-if = " 0.1.5"
1716wasm-bindgen = " 0.2.25"
1817
1918# The `console_error_panic_hook` crate provides better debugging of panics by
Original file line number Diff line number Diff line change 11use wasm_bindgen:: prelude:: * ;
22
3- cfg_if:: cfg_if! {
4- // When the `console_error_panic_hook` feature is enabled, we can call the
5- // `set_panic_hook` function to get better error messages if we ever panic.
6- if #[ cfg( feature = "console_error_panic_hook" ) ] {
7- use console_error_panic_hook:: set_once as set_panic_hook;
8- } else {
9- #[ inline]
10- fn set_panic_hook( ) { }
11- }
12- }
13-
14- cfg_if:: cfg_if! {
15- // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
16- // allocator.
17- if #[ cfg( feature = "wee_alloc" ) ] {
18- #[ global_allocator]
19- static ALLOC : wee_alloc:: WeeAlloc = wee_alloc:: WeeAlloc :: INIT ;
20- }
21- }
3+ // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
4+ // allocator.
5+ #[ cfg( feature = "wee_alloc" ) ]
6+ #[ global_allocator]
7+ static ALLOC : wee_alloc:: WeeAlloc = wee_alloc:: WeeAlloc :: INIT ;
228
239// Called by our JS entry point to run the example.
2410#[ wasm_bindgen]
@@ -37,3 +23,10 @@ pub fn run() -> Result<(), JsValue> {
3723
3824 Ok ( ( ) )
3925}
26+
27+ fn set_panic_hook ( ) {
28+ // When the `console_error_panic_hook` feature is enabled, we can call the
29+ // `set_panic_hook` function to get better error messages if we ever panic.
30+ #[ cfg( feature = "console_error_panic_hook" ) ]
31+ console_error_panic_hook:: set_once ( ) ;
32+ }
You can’t perform that action at this time.
0 commit comments