diff options
author | 2022-01-28 17:05:09 +0700 | |
---|---|---|
committer | 2022-01-28 21:37:16 +0700 | |
commit | 87b3e03d187237f665b376018ea5af0cc5f05814 (patch) | |
tree | 71509d53f85ed76b1ad2d187652d818230618767 /native | |
parent | 776724162aa4351310de9f88c7bb8d61b0abca04 (diff) | |
download | iced-87b3e03d187237f665b376018ea5af0cc5f05814.tar.gz iced-87b3e03d187237f665b376018ea5af0cc5f05814.tar.bz2 iced-87b3e03d187237f665b376018ea5af0cc5f05814.zip |
Enable `instant` only for `wasm32` targets
... and hide the dependency under a `time` module in `iced_native`
Diffstat (limited to 'native')
-rw-r--r-- | native/Cargo.toml | 5 | ||||
-rw-r--r-- | native/src/debug/basic.rs | 4 | ||||
-rw-r--r-- | native/src/lib.rs | 1 | ||||
-rw-r--r-- | native/src/mouse/click.rs | 2 | ||||
-rw-r--r-- | native/src/time.rs | 7 |
5 files changed, 16 insertions, 3 deletions
diff --git a/native/Cargo.toml b/native/Cargo.toml index d8e75a4e..499ad29e 100644 --- a/native/Cargo.toml +++ b/native/Cargo.toml @@ -14,7 +14,6 @@ debug = [] twox-hash = { version = "1.5", default-features = false } unicode-segmentation = "1.6" num-traits = "0.2" -instant = { version="0.1", features=["wasm-bindgen"] } [dependencies.iced_core] version = "0.4" @@ -28,3 +27,7 @@ features = ["thread-pool"] [dependencies.iced_style] version = "0.3" path = "../style" + +[target.'cfg(target_arch = "wasm32")'.dependencies.instant] +version = "0.1" +features = ["wasm-bindgen"] diff --git a/native/src/debug/basic.rs b/native/src/debug/basic.rs index a42f66ea..d706bb00 100644 --- a/native/src/debug/basic.rs +++ b/native/src/debug/basic.rs @@ -1,5 +1,7 @@ #![allow(missing_docs)] -use std::{collections::VecDeque, time}; +use crate::time; + +use std::collections::VecDeque; /// A bunch of time measurements for debugging purposes. #[derive(Debug)] diff --git a/native/src/lib.rs b/native/src/lib.rs index a5526e6d..bd50c6b2 100644 --- a/native/src/lib.rs +++ b/native/src/lib.rs @@ -49,6 +49,7 @@ pub mod renderer; pub mod subscription; pub mod svg; pub mod text; +pub mod time; pub mod touch; pub mod user_interface; pub mod widget; diff --git a/native/src/mouse/click.rs b/native/src/mouse/click.rs index 58cfda61..ec321387 100644 --- a/native/src/mouse/click.rs +++ b/native/src/mouse/click.rs @@ -1,6 +1,6 @@ //! Track mouse clicks. +use crate::time::Instant; use crate::Point; -use instant::Instant; /// A mouse click. #[derive(Debug, Clone, Copy)] diff --git a/native/src/time.rs b/native/src/time.rs new file mode 100644 index 00000000..5f95ee86 --- /dev/null +++ b/native/src/time.rs @@ -0,0 +1,7 @@ +//! Keep track of time, both in native and web platforms! + +#[cfg(target_arch = "wasm32")] +pub use instant::{Duration, Instant}; + +#[cfg(not(target_arch = "wasm32"))] +pub use std::time::{Duration, Instant}; |