From d02810a9c39e40773149cced17911c5cf54156e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Thu, 12 Jan 2023 06:24:44 +0100 Subject: [PATCH] Use `instant` instead of `wasm-timer` in `iced_core` --- core/Cargo.toml | 2 +- core/src/time.rs | 6 +++++- glutin/Cargo.toml | 1 - glutin/src/application.rs | 2 +- native/src/widget/text_input.rs | 3 +-- native/src/window.rs | 3 +-- native/src/window/event.rs | 3 ++- native/src/window/redraw_request.rs | 2 +- winit/Cargo.toml | 1 - winit/src/application.rs | 2 +- 10 files changed, 13 insertions(+), 12 deletions(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index c401f30a38..7be4b132f6 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -15,4 +15,4 @@ version = "0.6" optional = true [target.'cfg(target_arch = "wasm32")'.dependencies] -wasm-timer = { version = "0.2" } +instant = "0.1" diff --git a/core/src/time.rs b/core/src/time.rs index f496d1a4ba..9355ae6d84 100644 --- a/core/src/time.rs +++ b/core/src/time.rs @@ -1,9 +1,13 @@ //! Keep track of time, both in native and web platforms! #[cfg(target_arch = "wasm32")] -pub use wasm_timer::Instant; +pub use instant::Instant; + +#[cfg(target_arch = "wasm32")] +pub use instant::Duration; #[cfg(not(target_arch = "wasm32"))] pub use std::time::Instant; +#[cfg(not(target_arch = "wasm32"))] pub use std::time::Duration; diff --git a/glutin/Cargo.toml b/glutin/Cargo.toml index a458ee9e51..709b118b75 100644 --- a/glutin/Cargo.toml +++ b/glutin/Cargo.toml @@ -17,7 +17,6 @@ system = ["iced_winit/system"] [dependencies] log = "0.4" -instant = "0.1" [dependencies.glutin] version = "0.29" diff --git a/glutin/src/application.rs b/glutin/src/application.rs index a2096ee41a..da0af5c04e 100644 --- a/glutin/src/application.rs +++ b/glutin/src/application.rs @@ -11,11 +11,11 @@ use iced_winit::conversion; use iced_winit::futures; use iced_winit::futures::channel::mpsc; use iced_winit::renderer; +use iced_winit::time::Instant; use iced_winit::user_interface; use iced_winit::{Clipboard, Command, Debug, Event, Proxy, Settings}; use glutin::window::Window; -use instant::Instant; use std::mem::ManuallyDrop; #[cfg(feature = "tracing")] diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index e5b7d93a0c..8755b85d81 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -18,6 +18,7 @@ use crate::layout; use crate::mouse::{self, click}; use crate::renderer; use crate::text::{self, Text}; +use crate::time::{Duration, Instant}; use crate::touch; use crate::widget; use crate::widget::operation::{self, Operation}; @@ -28,8 +29,6 @@ use crate::{ Rectangle, Shell, Size, Vector, Widget, }; -use instant::{Duration, Instant}; - pub use iced_style::text_input::{Appearance, StyleSheet}; /// A field that can be filled with text. diff --git a/native/src/window.rs b/native/src/window.rs index 94201059dc..bd92730db1 100644 --- a/native/src/window.rs +++ b/native/src/window.rs @@ -12,8 +12,7 @@ pub use redraw_request::RedrawRequest; pub use user_attention::UserAttention; use crate::subscription::{self, Subscription}; - -use instant::Instant; +use crate::time::Instant; /// Subscribes to the frames of the window of the running application. /// diff --git a/native/src/window/event.rs b/native/src/window/event.rs index 64dd17d7c7..e2fb5e665b 100644 --- a/native/src/window/event.rs +++ b/native/src/window/event.rs @@ -1,4 +1,5 @@ -use instant::Instant; +use crate::time::Instant; + use std::path::PathBuf; /// A window-related event. diff --git a/native/src/window/redraw_request.rs b/native/src/window/redraw_request.rs index be5bd75750..3b4f0fd35e 100644 --- a/native/src/window/redraw_request.rs +++ b/native/src/window/redraw_request.rs @@ -1,4 +1,4 @@ -use instant::Instant; +use crate::time::Instant; /// A request to redraw a window. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] diff --git a/winit/Cargo.toml b/winit/Cargo.toml index 872b30c8cc..94aaa2cad3 100644 --- a/winit/Cargo.toml +++ b/winit/Cargo.toml @@ -21,7 +21,6 @@ application = [] window_clipboard = "0.2" log = "0.4" thiserror = "1.0" -instant = "0.1" [dependencies.winit] version = "0.27" diff --git a/winit/src/application.rs b/winit/src/application.rs index 4d7382ccad..8817939102 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -20,11 +20,11 @@ use iced_futures::futures::channel::mpsc; use iced_graphics::compositor; use iced_graphics::window; use iced_native::program::Program; +use iced_native::time::Instant; use iced_native::user_interface::{self, UserInterface}; pub use iced_native::application::{Appearance, StyleSheet}; -use instant::Instant; use std::mem::ManuallyDrop; #[cfg(feature = "trace")]