Skip to content

Commit ea6563f

Browse files
Merge pull request #124 from alexcrichton/no-cfg-if
Remove the cfg-if dependency
2 parents 560e03f + dfc704d commit ea6563f

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

crate/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ edition = "2018"
1313
crate-type = ["cdylib"]
1414

1515
[dependencies]
16-
cfg-if = "0.1.5"
1716
wasm-bindgen = "0.2.25"
1817

1918
# The `console_error_panic_hook` crate provides better debugging of panics by

crate/src/lib.rs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
11
use 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+
}

0 commit comments

Comments
 (0)