Enable instant only for wasm32 targets
... and hide the dependency under a `time` module in `iced_native`
This commit is contained in:
parent
776724162a
commit
87b3e03d18
6 changed files with 19 additions and 6 deletions
|
|
@ -14,7 +14,6 @@ debug = []
|
||||||
twox-hash = { version = "1.5", default-features = false }
|
twox-hash = { version = "1.5", default-features = false }
|
||||||
unicode-segmentation = "1.6"
|
unicode-segmentation = "1.6"
|
||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
instant = { version="0.1", features=["wasm-bindgen"] }
|
|
||||||
|
|
||||||
[dependencies.iced_core]
|
[dependencies.iced_core]
|
||||||
version = "0.4"
|
version = "0.4"
|
||||||
|
|
@ -28,3 +27,7 @@ features = ["thread-pool"]
|
||||||
[dependencies.iced_style]
|
[dependencies.iced_style]
|
||||||
version = "0.3"
|
version = "0.3"
|
||||||
path = "../style"
|
path = "../style"
|
||||||
|
|
||||||
|
[target.'cfg(target_arch = "wasm32")'.dependencies.instant]
|
||||||
|
version = "0.1"
|
||||||
|
features = ["wasm-bindgen"]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
#![allow(missing_docs)]
|
#![allow(missing_docs)]
|
||||||
use std::{collections::VecDeque, time};
|
use crate::time;
|
||||||
|
|
||||||
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
/// A bunch of time measurements for debugging purposes.
|
/// A bunch of time measurements for debugging purposes.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ pub mod renderer;
|
||||||
pub mod subscription;
|
pub mod subscription;
|
||||||
pub mod svg;
|
pub mod svg;
|
||||||
pub mod text;
|
pub mod text;
|
||||||
|
pub mod time;
|
||||||
pub mod touch;
|
pub mod touch;
|
||||||
pub mod user_interface;
|
pub mod user_interface;
|
||||||
pub mod widget;
|
pub mod widget;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
//! Track mouse clicks.
|
//! Track mouse clicks.
|
||||||
|
use crate::time::Instant;
|
||||||
use crate::Point;
|
use crate::Point;
|
||||||
use instant::Instant;
|
|
||||||
|
|
||||||
/// A mouse click.
|
/// A mouse click.
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
|
|
||||||
7
native/src/time.rs
Normal file
7
native/src/time.rs
Normal file
|
|
@ -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};
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
//! Listen and react to time.
|
//! Listen and react to time.
|
||||||
|
pub use crate::runtime::time::{Duration, Instant};
|
||||||
|
|
||||||
use crate::Subscription;
|
use crate::Subscription;
|
||||||
|
|
||||||
/// Returns a [`Subscription`] that produces messages at a set interval.
|
/// Returns a [`Subscription`] that produces messages at a set interval.
|
||||||
///
|
///
|
||||||
/// The first message is produced after a `duration`, and then continues to
|
/// The first message is produced after a `duration`, and then continues to
|
||||||
/// produce more messages every `duration` after that.
|
/// produce more messages every `duration` after that.
|
||||||
pub fn every(
|
pub fn every(duration: Duration) -> Subscription<Instant> {
|
||||||
duration: std::time::Duration,
|
|
||||||
) -> Subscription<std::time::Instant> {
|
|
||||||
iced_futures::time::every(duration)
|
iced_futures::time::every(duration)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue