File tree Expand file tree Collapse file tree 4 files changed +19
-13
lines changed Expand file tree Collapse file tree 4 files changed +19
-13
lines changed Original file line number Diff line number Diff line change @@ -13,13 +13,19 @@ Timeouts for futures.
13
13
"""
14
14
15
15
[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 }
22
20
23
21
[dev-dependencies ]
24
22
async-std = { version = " 1.0.1" , features = [" attributes" ] }
25
23
futures = " 0.3.1"
24
+
25
+ [features ]
26
+ wasm-bindgen = [
27
+ " wasm-timer" ,
28
+ " wasm-bindgen-crate" ,
29
+ " futures" ,
30
+ " web-sys"
31
+ ]
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ use std::sync::Arc;
6
6
use std:: sync:: Mutex ;
7
7
use std:: task:: Context ;
8
8
use std:: time:: Duration ;
9
- use wasm_bindgen :: { closure:: Closure , JsCast } ;
9
+ use wasm_bindgen_crate :: { closure:: Closure , JsCast } ;
10
10
11
11
use crate :: { Instant , Timer , TimerHandle } ;
12
12
Original file line number Diff line number Diff line change 19
19
mod arc_list;
20
20
mod atomic_waker;
21
21
mod delay;
22
- #[ cfg( not( all ( target_arch = "wasm32" , target_os = "unknown" ) ) ) ]
22
+ #[ cfg( not( feature = "wasm-bindgen" ) ) ]
23
23
mod global_native;
24
- #[ cfg( all ( target_arch = "wasm32" , target_os = "unknown" ) ) ]
24
+ #[ cfg( feature = "wasm-bindgen" ) ]
25
25
mod global_wasm;
26
26
mod heap;
27
27
mod heap_timer;
@@ -34,7 +34,7 @@ use heap_timer::HeapTimer;
34
34
use timer:: { ScheduledTimer , Timer , TimerHandle } ;
35
35
36
36
pub use self :: delay:: Delay ;
37
- #[ cfg( not( all ( target_arch = "wasm32" , target_os = "unknown" ) ) ) ]
37
+ #[ cfg( not( feature = "wasm-bindgen" ) ) ]
38
38
use std:: time:: Instant ;
39
- #[ cfg( all ( target_arch = "wasm32" , target_os = "unknown" ) ) ]
39
+ #[ cfg( feature = "wasm-bindgen" ) ]
40
40
use wasm_timer:: Instant ;
Original file line number Diff line number Diff line change @@ -277,7 +277,7 @@ impl Default for TimerHandle {
277
277
// handle which will return errors when timer objects are attempted to
278
278
// be associated.
279
279
if fallback == 0 {
280
- #[ cfg( not( all ( target_arch = "wasm32" , target_os = "unknown" ) ) ) ]
280
+ #[ cfg( not( feature = "wasm-bindgen" ) ) ]
281
281
{
282
282
let helper = match crate :: global_native:: HelperThread :: new ( ) {
283
283
Ok ( helper) => helper,
@@ -298,7 +298,7 @@ impl Default for TimerHandle {
298
298
}
299
299
}
300
300
301
- #[ cfg( all ( target_arch = "wasm32" , target_os = "unknown" ) ) ]
301
+ #[ cfg( feature = "wasm-bindgen" ) ]
302
302
{
303
303
let handle = crate :: global_wasm:: run ( ) ;
304
304
You can’t perform that action at this time.
0 commit comments