Skip to content

Commit bfbe40d

Browse files
committed
Use feature flag instead
1 parent e394596 commit bfbe40d

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

Cargo.toml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,19 @@ Timeouts for futures.
1313
"""
1414

1515
[dependencies]
16-
17-
[target.wasm32-unknown-unknown.dependencies]
18-
wasm-timer = "0.2.4"
19-
wasm-bindgen = "0.2.55"
20-
futures = "0.3.1"
21-
web-sys = "0.3.32"
16+
wasm-timer = { version = "0.2.4", optional = true }
17+
wasm-bindgen-crate = { package = "wasm-bindgen", version = "0.2.55", optional = true }
18+
futures = { version = "0.3.1", optional = true }
19+
web-sys = { version = "0.3.32", optional = true }
2220

2321
[dev-dependencies]
2422
async-std = { version = "1.0.1", features = ["attributes"] }
2523
futures = "0.3.1"
24+
25+
[features]
26+
wasm-bindgen = [
27+
"wasm-timer",
28+
"wasm-bindgen-crate",
29+
"futures",
30+
"web-sys"
31+
]

src/global_wasm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::sync::Arc;
66
use std::sync::Mutex;
77
use std::task::Context;
88
use std::time::Duration;
9-
use wasm_bindgen::{closure::Closure, JsCast};
9+
use wasm_bindgen_crate::{closure::Closure, JsCast};
1010

1111
use crate::{Instant, Timer, TimerHandle};
1212

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
mod arc_list;
2020
mod atomic_waker;
2121
mod delay;
22-
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
22+
#[cfg(not(feature = "wasm-bindgen"))]
2323
mod global_native;
24-
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
24+
#[cfg(feature = "wasm-bindgen")]
2525
mod global_wasm;
2626
mod heap;
2727
mod heap_timer;
@@ -34,7 +34,7 @@ use heap_timer::HeapTimer;
3434
use timer::{ScheduledTimer, Timer, TimerHandle};
3535

3636
pub use self::delay::Delay;
37-
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
37+
#[cfg(not(feature = "wasm-bindgen"))]
3838
use std::time::Instant;
39-
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
39+
#[cfg(feature = "wasm-bindgen")]
4040
use wasm_timer::Instant;

src/timer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ impl Default for TimerHandle {
277277
// handle which will return errors when timer objects are attempted to
278278
// be associated.
279279
if fallback == 0 {
280-
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
280+
#[cfg(not(feature = "wasm-bindgen"))]
281281
{
282282
let helper = match crate::global_native::HelperThread::new() {
283283
Ok(helper) => helper,
@@ -298,7 +298,7 @@ impl Default for TimerHandle {
298298
}
299299
}
300300

301-
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
301+
#[cfg(feature = "wasm-bindgen")]
302302
{
303303
let handle = crate::global_wasm::run();
304304

0 commit comments

Comments
 (0)