From 4a16276f0bf1dced8661dbdecc1f1a7b7960f18d Mon Sep 17 00:00:00 2001 From: misssonder <819643718@qq.com> Date: Mon, 5 Aug 2024 19:39:54 +0800 Subject: [PATCH 1/3] Add web-time --- Cargo.toml | 6 +++--- src/packages/time_basic.rs | 2 +- src/types/dynamic.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d43de4210..f339d8877 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -118,9 +118,9 @@ no_std = ["no-std-compat", "num-traits/libm", "core-error", "libm", "hashbrown", #! ### JavaScript Interface for WASM ## Use [`wasm-bindgen`](https://crates.io/crates/wasm-bindgen) as JavaScript interface. -wasm-bindgen = ["getrandom/js", "instant/wasm-bindgen"] +wasm-bindgen = ["getrandom/js"] ## Use [`stdweb`](https://crates.io/crates/stdweb) as JavaScript interface. -stdweb = ["getrandom/js", "instant/stdweb"] +stdweb = ["getrandom/js"] #! ### Features used in testing environments only @@ -156,7 +156,7 @@ codegen-units = 1 #panic = 'abort' # remove stack backtrace for no-std [target.'cfg(target_family = "wasm")'.dependencies] -instant = { version = "0.1.10" } # WASM implementation of std::time::Instant +web-time = { version = "1.1.0" }# WASM implementation of std::time::Instant [package.metadata.docs.rs] features = ["document-features", "metadata", "serde", "internals", "decimal", "debugging"] diff --git a/src/packages/time_basic.rs b/src/packages/time_basic.rs index 9bd4f98c4..668bd81c3 100644 --- a/src/packages/time_basic.rs +++ b/src/packages/time_basic.rs @@ -11,7 +11,7 @@ use crate::FLOAT; use std::time::{Duration, Instant}; #[cfg(all(target_family = "wasm", target_os = "unknown"))] -use instant::{Duration, Instant}; +use web_time::{Duration, Instant}; def_package! { /// Package of basic timing utilities. diff --git a/src/types/dynamic.rs b/src/types/dynamic.rs index 9aaf4d031..7fa059303 100644 --- a/src/types/dynamic.rs +++ b/src/types/dynamic.rs @@ -20,7 +20,7 @@ pub use std::time::Instant; #[cfg(not(feature = "no_time"))] #[cfg(all(target_family = "wasm", target_os = "unknown"))] -pub use instant::Instant; +pub use web_time::Instant; #[cfg(not(feature = "no_index"))] use crate::{Array, Blob}; From 4a9a50be4b88daf0e536c2abe1c9ed8d5f0cee9c Mon Sep 17 00:00:00 2001 From: misssonder <819643718@qq.com> Date: Mon, 5 Aug 2024 23:08:09 +0800 Subject: [PATCH 2/3] Fix no_std bug --- Cargo.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f339d8877..aed5f7634 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -156,7 +156,8 @@ codegen-units = 1 #panic = 'abort' # remove stack backtrace for no-std [target.'cfg(target_family = "wasm")'.dependencies] -web-time = { version = "1.1.0" }# WASM implementation of std::time::Instant +[target.'cfg(not(feature = "no_time"))'.dependencies] +web-time = { version = "1.1.0" ,optional = true}# WASM implementation of std::time::Instant [package.metadata.docs.rs] features = ["document-features", "metadata", "serde", "internals", "decimal", "debugging"] From e8c3d2f4bcbaa61f51ebbb08b0ca31f29d6909af Mon Sep 17 00:00:00 2001 From: misssonder <819643718@qq.com> Date: Tue, 6 Aug 2024 19:51:40 +0800 Subject: [PATCH 3/3] Fix wasm build --- Cargo.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index aed5f7634..18240dfb5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -155,9 +155,8 @@ codegen-units = 1 #opt-level = "z" # optimize for size #panic = 'abort' # remove stack backtrace for no-std -[target.'cfg(target_family = "wasm")'.dependencies] -[target.'cfg(not(feature = "no_time"))'.dependencies] -web-time = { version = "1.1.0" ,optional = true}# WASM implementation of std::time::Instant +[target.'cfg(all(target_family = "wasm", not(feature = "no_time")))'.dependencies] +web-time = { version = "1.1.0" }# WASM implementation of std::time::Instant [package.metadata.docs.rs] features = ["document-features", "metadata", "serde", "internals", "decimal", "debugging"]