Skip to content
This repository was archived by the owner on Jun 22, 2023. It is now read-only.

Commit 15e8835

Browse files
committed
fix: use instant::Instant instead of std::time::Instant for better compatibility
1 parent 64c812a commit 15e8835

File tree

4 files changed

+10
-199
lines changed

4 files changed

+10
-199
lines changed

Cargo.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ name = "wasm-timer"
33
edition = "2018"
44
description = "Abstraction over std::time::Instant and futures-timer that works on WASM"
55
version = "0.2.5"
6-
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
6+
authors = ["Youngjoon Lee <taxihighway@gmail.com>"]
77
license = "MIT"
8-
repository = "https://github.com/tomaka/wasm-timer"
8+
repository = "https://github.com/youngjoon-lee/wasm-timer"
9+
10+
# [features]
11+
# wasm-bindgen = ["instant/wasm-bindgen"]
912

1013
[dependencies]
1114
futures = "0.3.1"
15+
instant = "0.1.12"
1216
parking_lot = "0.11"
1317
pin-utils = "0.1.0"
1418

@@ -17,6 +21,7 @@ js-sys = "0.3.31"
1721
wasm-bindgen = "0.2.37"
1822
wasm-bindgen-futures = "0.4.4"
1923
web-sys = { version = "0.3.31", features = ["Performance", "Window"] }
24+
instant = { version = "0.1.12", features = ["wasm-bindgen"] }
2025

2126
[dev-dependencies]
2227
async-std = "1.0"

src/lib.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@
2020

2121
pub use timer::*;
2222

23-
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
24-
pub use std::time::{Instant, SystemTime, UNIX_EPOCH};
25-
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
26-
pub use wasm::*;
23+
pub use instant::{Instant, SystemTime};
24+
pub use std::time::UNIX_EPOCH;
2725

2826
mod timer;
29-
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
30-
mod wasm;

src/timer/global/desktop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use instant::Instant;
12
use std::future::Future;
23
use std::io;
34
use std::mem::{self, ManuallyDrop};
@@ -6,7 +7,6 @@ use std::sync::Arc;
67
use std::task::{Context, RawWaker, RawWakerVTable, Waker};
78
use std::thread;
89
use std::thread::Thread;
9-
use std::time::Instant;
1010

1111
use pin_utils::pin_mut;
1212

src/wasm.rs

Lines changed: 0 additions & 190 deletions
This file was deleted.

0 commit comments

Comments
 (0)