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"
13
13
crate-type = [" cdylib" ]
14
14
15
15
[dependencies ]
16
- cfg-if = " 0.1.5"
17
16
wasm-bindgen = " 0.2.25"
18
17
19
18
# The `console_error_panic_hook` crate provides better debugging of panics by
Original file line number Diff line number Diff line change 1
1
use wasm_bindgen:: prelude:: * ;
2
2
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 ;
22
8
23
9
// Called by our JS entry point to run the example.
24
10
#[ wasm_bindgen]
@@ -37,3 +23,10 @@ pub fn run() -> Result<(), JsValue> {
37
23
38
24
Ok ( ( ) )
39
25
}
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